

(objSDF. SimpleDateFormat objSDF = new SimpleDateFormat(strDateFormat) //Date format string is passed as an argument to the Date format object String strDateFormat = "hh:mm:ss a dd-MMM-yyyy" //Date format is Specified import ĭate objDate = new Date() // Current System Date and time is assigned to objDate If you mistake M with m, you will undesired results! Tip: Be careful with the letter capitalization. The appropriate date format specified will be- hh:mm:ss a dd-MMM-yyyy The appropriate date format specified will be- yyyy.MM.dd HH:mm:ss zzz You can use the above characters to specify the format-ġ) Date format required: 2012.10.23 20:20:45 PST Java provides a class called a SimpleDateFormat that allows you to format and parse dates in the as per your requirements. Letterĭay number of week (1 = Monday, …, 7 = Sunday)ĭon’t worry, you don’t need to remember all of these, they can be referred anytime you need to format a particular date. Let us now learn the ABC’s of the date format. You all must have learned the alphabets in your kindergarten …. In above example date shown in default format, If we want to show the date and time in another format, first understand the Formatting of date. Display the Date & Time using toString() Instantiate a Date object by invoking its constructor for properties with format of utc-millisec or date-time for arrays of any of these types. You can use the Date object by invoking the constructor of Date class as follows: import Generate Plain Old Java Objects from JSON or JSON-Schema.
