![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9326 Articles for Object Oriented Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
392 Views
The “kk” format in Java Date is used to format hour in 01-24 format. Use SimpleDateFormat("kk") to get the same format.// displaying hour in kk format SimpleDateFormat simpleformat = new SimpleDateFormat("kk"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in kk format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
996 Views
The “k” format in Java Date is used to format hour in 1-24 format. Use SimpleDateFormat("k") to get the same format.// displaying hour in k format simpleformat = new SimpleDateFormat("k"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in k format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the following package is imported.import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
3K+ Views
The “HH” format in Java Date is like 00, 01, 02, 03, … 23 hour. Use SimpleDateFormat("HH") to get the same format and in that way you can format hour.// displaying hour in HH format SimpleDateFormat simpleformat = new SimpleDateFormat("HH"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in HH format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the following package is imported.import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
292 Views
The “H” format in Java Date is like 0, 1, 2, 3, … 23 hour. 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 package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
91 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 are anagram.A program that demonstrates this is given as follows −Example Live Demopublic class Example { public static void main (String[] args) { long x = 12, y = 3; if(Long.bitCount(x) == Long.bitCount(y)) ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
256 Views
The “hh” format in Java Date is like 01 – 12 hour in AM/ PM. Use SimpleDateFormat("hh") to get the same format;// displaying hour in hh format SimpleDateFormat simpleformat = new SimpleDateFormat("hh"); String strHour2 = simpleformat.format(new Date()); System.out.println("Hour in hh format = "+strHour2);Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
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 package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
402 Views
The dd format in Java Date is like 05, 06, 07, 08, 09, etc. i.e. with two-letter digit. Let us use it.// displaying day in dd format SimpleDateFormat simpleformat = new SimpleDateFormat("dd"); String strDay = simpleformat.format(new Date()); System.out.println("Day in dd format = "+strDay);Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
116 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 following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
EEEEE format is used in Java Date to format day of week like Monday, Tuesday, Wednesday, etc. Let us use it −// displaying day of week SimpleDateFormat simpleformat = new SimpleDateFormat("EEEE"); String strDayofWeek = simpleformat.format(new Date()); System.out.println("Day of Week = "+strDayofWeek);Above, we have used the SimpleDateFormat class, therefore the following package is imported −import java.text.SimpleDateFormat;The following is an example −Example Live Demoimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ... Read More