date format example
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
public class CurrentDateTimeExample1 {
public static void main(String[] args) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
System.out.println(dtf.format(now));
}
}
4
3
Pattern Result
---------------- -------
DateFormat.yMd() -> 7/10/1996
DateFormat('yMd') -> 7/10/1996
DateFormat.yMMMMd('en_US') -> July 10, 1996
DateFormat.jm() -> 5:08 PM
DateFormat.yMd().add_jm() -> 7/10/1996 5:08 PM
DateFormat.Hm() -> 17:08 // force 24 hour time
Thank you!
3
0
Are there any code examples left?
New code examples in category Other