- Trending Categories
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 34494 Articles for Programming
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
264 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)
200 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)
406 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)
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 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
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 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)
6K+ Views
Let us format date in mm-dd-yyyy hh:mm:ss format −// displaying date in mm-dd-yyyy hh:mm:ss format Format f = new SimpleDateFormat("mm-dd-yyyy hh:mm:ss"); String str = f.format(new Date()); System.out.println("Current Date in MM-dd-yyyy hh:mm:ss format = "+str);Since we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date −import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date;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 ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
3K+ Views
Using the SimpleDateFormat(“MMM”) to display three-letter month −Format f = new SimpleDateFormat("MMM"); String strMonth = f.format(new Date()); System.out.println("Month (Three-letter format) = "+strMonth);Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date −import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date;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 Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("E, ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
410 Views
Using the SimpleDateFormat(“yyyy”) to display year −// displaying year Format f = new SimpleDateFormat("yyyy"); String strYear = f.format(new Date()); System.out.println("Year = "+strYear);Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date −import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date;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 Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("E, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
4K+ Views
Using the SimpleDateFormat(“E, dd MMM yyyy HH:mm:ss Z”), wherein E is for Day of Week −// displaying current date and time Calendar cal = Calendar.getInstance(); SimpleDateFormat simpleformat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z"); System.out.println("Today's date and time = "+simpleformat.format(cal.getTime()));Since we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date −import java.text.Format; import java.text.SimpleDateFormat; import java.util.Date;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 { ... Read More