Also read : Clock , time Zone in java 8, Display All TimeZone SORTED By name, TIME (or offset) in java 8
Display ISO_DATE_TIME - formatted date and time in java 8 >
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* Display ISO_DATE_TIME - formatted date and time in java 8
*/
public class IsoDateExample {
public static void main(String[] args) {
//-----------------------Display ISO_DATE - formatted date
DateTimeFormatter ISO_DATE_formatter = DateTimeFormatter.ISO_DATE;
System.out.println("ISO_DATE: " + ISO_DATE_formatter.format(LocalDate.now()));
//-----------------------Display ISO_DATE_TIME - formatted date and time
DateTimeFormatter ISO_DATE_TIME_formatter = DateTimeFormatter.ISO_DATE_TIME;
System.out.println("ISO_DATE_TIME: " + ISO_DATE_TIME_formatter.format(LocalDateTime.now()));
}
}
/* OUTPUT
ISO_DATE: 2017-05-12
ISO_DATE_TIME: 2017-05-12T19:21:10.439
*/
|
Having any doubt? or you you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.