Date (time) to 24-hour format in Java

Date (time) to 24-hour format in Java

Use SimpleDateFormat to format a date (time) into a 24-hour format in Java.

If you use “hhmm”, 1310 becomes 0110.

If you use “HHmm”, 1310 becomes 1310 24-hour notation.

Date date = new Date();
DateFormat sdf = new SimpleDateFormat("yyMMddHHmm");
String dt = sdf.format(date);

コメント

Discover more from 株式会社CONFRAGE ITソリューション事業部

Subscribe now to keep reading and get access to the full archive.

Continue reading

Copied title and URL