Wednesday, May 7, 2014

ZonedDateTime example

Example of using ZonedDateTime:

ZonedDateTime
ZonedDateTime example

package javazoneddatetime;

import java.time.ZonedDateTime;

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

    public static void main(String[] args) {
        ZonedDateTime zonedDateTime = 
            ZonedDateTime.parse("2007-12-03T10:15:30+01:00[Europe/Paris]");
        System.out.println("zonedDateTime: " + zonedDateTime.toString());
        System.out.println("Zone: " + zonedDateTime.getZone());
        System.out.println("Offset: " + zonedDateTime.getOffset());
        System.out.println("Year: " + zonedDateTime.getYear());
        System.out.println("Month: " + zonedDateTime.getMonth());
        System.out.println("DayOfMonth: " + zonedDateTime.getDayOfMonth());
        System.out.println("Hour: " + zonedDateTime.getHour());
        System.out.println("Minute: " + zonedDateTime.getMinute());
        System.out.println("Second: " + zonedDateTime.getSecond());
        System.out.println("MonthValue: " + zonedDateTime.getMonthValue());
        System.out.println("DayOfYear: " + zonedDateTime.getDayOfYear());
        System.out.println("DayOfWeek: " + zonedDateTime.getDayOfWeek());
        System.out.println("Nano: " + zonedDateTime.getNano());
        
    }
    
}


No comments:

Post a Comment