ZonedDateTime ofStrict(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone) example

Description

ZonedDateTime ofStrict(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone) creates an instance of ZonedDateTime strictly validating the combination of local date-time, offset and zone ID.

Syntax

ofStrict has the following syntax.


public static ZonedDateTime ofStrict(LocalDateTime localDateTime,    
                                     ZoneOffset offset,    
                                     ZoneId zone)

Example

The following example shows how to use ofStrict.


import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
/*from  w  ww.  j  a  v a  2  s.c o  m*/
public class Main {
  public static void main(String[] args) {
    ZonedDateTime z = ZonedDateTime.ofStrict(LocalDateTime.now(),ZoneOffset.UTC,ZoneId.systemDefault());
    
    System.out.println(z);

  }
}




















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset