Saturday, May 10, 2014

print ZonedDateTime with format



package javazoneddatetime;

import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @web java-buddy.blogspot.com
 */
public class JavaZonedDateTime {

    public static void main(String[] args) {
        ZonedDateTime zdt = 
            ZonedDateTime.parse("2007-12-03T10:15:30+01:00[Europe/Paris]");
        
        System.out.println("BASIC_ISO_DATE: \t" + zdt.format(DateTimeFormatter.BASIC_ISO_DATE));
        System.out.println("ISO_LOCAL_DATE: \t" + zdt.format(DateTimeFormatter.ISO_LOCAL_DATE));
        System.out.println("ISO_OFFSET_DATE: \t" + zdt.format(DateTimeFormatter.ISO_OFFSET_DATE));
        System.out.println("ISO_DATE: \t\t" + zdt.format(DateTimeFormatter.ISO_DATE));
        System.out.println("ISO_LOCAL_TIME: \t" + zdt.format(DateTimeFormatter.ISO_LOCAL_TIME));
        System.out.println("ISO_OFFSET_TIME: \t" + zdt.format(DateTimeFormatter.ISO_OFFSET_TIME));
        System.out.println("ISO_TIME: \t\t" + zdt.format(DateTimeFormatter.ISO_TIME));
        System.out.println("ISO_LOCAL_DATE_TIME: \t" + zdt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
        System.out.println("ISO_OFFSET_DATE_TIME: \t" + zdt.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME));
        System.out.println("ISO_ZONED_DATE_TIME: \t" + zdt.format(DateTimeFormatter.ISO_ZONED_DATE_TIME));
        System.out.println("ISO_DATE_TIME: \t\t" + zdt.format(DateTimeFormatter.ISO_DATE_TIME));
        System.out.println("ISO_ORDINAL_DATE: \t" + zdt.format(DateTimeFormatter.ISO_ORDINAL_DATE));
        System.out.println("ISO_WEEK_DATE: \t\t" + zdt.format(DateTimeFormatter.ISO_WEEK_DATE));
        System.out.println("ISO_INSTANT: \t\t" + zdt.format(DateTimeFormatter.ISO_INSTANT));
        System.out.println("RFC_1123_DATE_TIME: \t" + zdt.format(DateTimeFormatter.RFC_1123_DATE_TIME));
    }
    
}

No comments:

Post a Comment