The java.time framework is built into Java 8 and later. These classes supplant the old troublesome date-time classes such as java.util.Date, .Calendar, & java.text.SimpleDateFormat. Now in maintenance mode, the Joda-Time project also advises migration to java.time. To learn more, see the Oracle Tutorial. And search Stack Overflow for many
Formatting are CASE-SENSITIVE so USE MM for month not mm (this is for minute) and yyyy For Reference you can use following cheatsheet.. G Era designator Text AD y Year Year 1996; 96 Y Week year Year 2009; 09 M Month in year Month July; Jul; 07 w Week in year Number 27 W Week in month Number 2 D Day in year Number 189 d Day in month Number 10 F Day of week in month Number 2 E Day name in week In the following example Java code, we learn how to write Java program to use the DateUtil class above to get the last Date of the current year value. The output as below. Today: Wed Aug 17 21:17:17 ICT 2022 Last Date of current year: Sat Dec 31 23:59:59 ICT 2022. But it is showing the date in 'yyyy-m-d' format and I want it in 'yyyy-mm-dd' format. I think i can use. Date date = new Date (); SimpleDateFormat sdf = new SimpleDateFormat ("yyyy/MM/dd"); txt_date.setText (sdf.format (date)); To get the current date in 'yyyy-mm-dd' format but what to do about the date of the next day? . 170 253 265 356 47 304 304 69