Karthikeya Boyini has Published 2383 Articles

Format date with DateFormat.MEDIUM in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

2K+ Views

DateFormat.MEDIUM is a constant for medium style pattern.Firstly, we will create date object −Date dt = new Date(); DateFormat dateFormat;Let us format date for different locale with DateFormat.MEDIUM −// CHINESE dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.CHINESE); // CANADA dateFormat = DateFormat.getDateInstance(DateFormat. MEDIUM, Locale.CANADA);The following is an example −Example Live Demoimport java.text.DateFormat; import java.util.Date; ... Read More

Formatting day of week using SimpleDateFormat in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

199 Views

E format is used in Java Date to format day of week like Mon, Tue, Wed, etc. Let us use it.// displaying day of week SimpleDateFormat simpleformat = new SimpleDateFormat("E"); String strDayofWeek = simpleformat.format(new Date()); System.out.println("Day of Week = "+strDayofWeek);Above, we have used the SimpleDateFormat class, therefore the following package ... Read More

Improve MySQL Search Performance with wildcards (%%)?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

359 Views

No, MySQL won’t improve search performance whenever you have leading wildcards because MySQL will be unable to use the index. If you change to ‘anyLetter%’ then it will be able to use indexThe below syntax is better to use with trailing wildcards. The syntax is as follows −SELECT *FROM yourTableName ... Read More

Java Program to return the hexadecimal value of the supplied byte array

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

101 Views

The following is the supplied byte array −byte[] b = new byte[]{'x', 'y', 'z'};We have created a custom method “display” here and passed the byte array value. The same method converts byte array to hex string −public static String display(byte[] b1){    StringBuilder strBuilder = new StringBuilder();    for(byte val ... Read More

Formatting day in d format in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

117 Views

The d format is used in Java Date to format day like 1, 2, 3, 4, etc. Let us use it.// displaying day in d format SimpleDateFormat simpleformat = new SimpleDateFormat("d"); String strDay = simpleformat.format(new Date()); System.out.println("Day in d format = "+strDay);Above, we have used the SimpleDateFormat class, therefore the ... Read More

MySQL show tables sort by table name?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

952 Views

You can sort the table_name property from INFORMATION_SCHEMA.TABLES with ORDER BY clause. Sort in ascending order or descending order with the help of ASC or DESC respectively. The syntax is as follows −SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema='yourDatabaseName' ORDER BY table_name DESC;Use the database with ... Read More

Display hour in h (1-12 in AM/PM) format in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

198 Views

The h format in Java Date is like 1-12 hour in AM/ PM. Use SimpleDateFormat("h") to get the same format;// displaying hour in h format SimpleDateFormat simpleformat = new SimpleDateFormat("h"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in h format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the following ... Read More

How to develop or migrate apps for iPhone 5 screen resolution?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

78 Views

At the release of iPhone 5, it’s resolution and aspect ratio was different (640 x 1136 pixels), hence it was tough to migrate applications from iPhone 4 sizes to the newer iPhone. But later with the release of iOS 8, size classes and abstract screen sizes were also introduced to ... Read More

MySQL- GROUP and COUNT by date?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

2K+ Views

You can use GROUP BY clause and COUNT() function for this. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, ..N, COUNT(*) as anyAliasName FROM yourTableName GROUP BY yourColumnName1, yourColumnName2;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ... Read More

Java program to check if binary representations of two numbers are anagram

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:24

92 Views

The binary representations of two numbers are anagrams if they have the same number of 0’a and 1’s. An example of this is given as follows −Number 1 = 3 Binary representation of Number 1 = 0011 Number 2 = 12 Binary representation of Number 2 = 1100The two numbers ... Read More

Advertisements