Example usage for java.time OffsetDateTime atZoneSameInstant

List of usage examples for java.time OffsetDateTime atZoneSameInstant

Introduction

In this page you can find the example usage for java.time OffsetDateTime atZoneSameInstant.

Prototype

public ZonedDateTime atZoneSameInstant(ZoneId zone) 

Source Link

Document

Combines this date-time with a time-zone to create a ZonedDateTime ensuring that the result has the same instant.

Usage

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    ZonedDateTime d = o.atZoneSameInstant(ZoneId.systemDefault());
    System.out.println(d);//from   ww w  . j  a  va 2 s . c  o m
}

From source file:org.apache.drill.test.TestBuilder.java

/**
 * Helper method for the timestamp values that depend on the local timezone
 * @param value expected timestamp value in UTC
 * @return LocalDateTime value for the local timezone
 *///from  w w  w.  j a v a2  s .co  m
public static LocalDateTime convertToLocalDateTime(String value) {
    OffsetDateTime utcDateTime = LocalDateTime.parse(value, DateUtility.getDateTimeFormatter())
            .atOffset(ZoneOffset.UTC);
    return utcDateTime.atZoneSameInstant(ZoneOffset.systemDefault()).toLocalDateTime();
}