Friday, May 9, 2014

Conversion between ZonedDateTime and GregorianCalendar

package javazoneddatetime;

import java.time.ZonedDateTime;
import java.util.GregorianCalendar;

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

    public static void main(String[] args) {
        ZonedDateTime zonedDateTime1 = 
            ZonedDateTime.parse("2007-12-03T10:15:30+01:00[Europe/Paris]");
        GregorianCalendar gregorianCalendar = GregorianCalendar.from(zonedDateTime1);
        ZonedDateTime zonedDateTime2 = gregorianCalendar.toZonedDateTime();
        
        System.out.println("zonedDateTime1: " + zonedDateTime1.toString());
        System.out.println("gregorianCalendar: " + gregorianCalendar);
        System.out.println("zonedDateTime2: " + zonedDateTime2.toString());
    }
    
}


Conversion between ZonedDateTime and GregorianCalendar

No comments:

Post a Comment