
("toZonedDateTime(): " + offsetDT.toZonedDateTime()) ("toLocalTime() : " + offsetDT.toLocalTime()) ("toLocalDateTime(): " + offsetDT.toLocalDateTime()) ("toLocalDate() : " + offsetDT.toLocalDate()) ("toInstant() : " + offsetDT.toInstant()) ("toEpochSecond() : " + offsetDT.toEpochSecond()) ("SECOND_OF_DAY : " + offsetDT.getLong(ChronoField.SECOND_OF_DAY)) ("MINUTE_OF_DAY : " + offsetDT.getLong(ChronoField.MINUTE_OF_DAY)) ("SECOND_OF_MINUTE : " + offsetDT.get(ChronoField.SECOND_OF_MINUTE)) ("MINUTE_OF_HOUR : " + offsetDT.get(ChronoField.MINUTE_OF_HOUR)) ("HOUR_OF_DAY : " + offsetDT.get(ChronoField.HOUR_OF_DAY))


("YEAR : " + offsetDT.get(ChronoField.YEAR))

("MONTH_OF_YEAR : " + offsetDT.get(ChronoField.MONTH_OF_YEAR)) ("DAY_OF_MONTH : " + offsetDT.get(ChronoField.DAY_OF_MONTH)) ("DayOfYear : " + offsetDT.getDayOfYear()) ("DayOfWeek : " + offsetDT.getDayOfWeek()) ("MonthValue : " + offsetDT.getMonthValue()) ("DayOfMonth : " + offsetDT.getDayOfMonth()) OffsetDateTime offsetDT = OffsetDateTime.now() ZonedDateTime toZonedDateTime(): Converts this date-time to a ZonedDateTime using the offset as the zone ID.OffsetTime toOffsetTime(): Converts this date-time to an OffsetTime.LocalTime toLocalTime(): Gets the LocalTime part of this date-time.LocalDateTime toLocalDateTime(): Gets the LocalDateTime part of this date-time.LocalDate toLocalDate(): Gets the LocalDate part of this date-time.Instant toInstant(): Converts this date-time to an Instant.long toEpochSecond(): Converts this date-time to the number of seconds from the epoch of.int getSecond(): Gets the second-of-minute field.Īnd following methods can be used to get another class (or convert) from an OffsetDateTime instance:.ZoneOffset getOffset(): Gets the zone offset, such as '+01:00'.int getNano(): Gets the nano-of-second field.int getMonthValue(): Gets the month-of-year field from 1 to 12.Month getMonth(): Gets the month-of-year field using the Month enum.int getMinute(): Gets the minute-of-hour field.long getLong(TemporalField field): Gets the value of the specified field from this date-time as a long.int getHour(): Gets the hour-of-day field.int getDayOfYear(): Gets the day-of-year field.DayOfWeek getDayOfWeek(): Gets the day-of-week field, which is an enum DayOfWeek.int getDayOfMonth(): Gets the day-of-month field.int get(TemporalField field): Gets the value of the specified field from this date-time as an int.OffsetDateTime9: T08:20:45+07:00 Getting Information from an OffsetDateTimeįollowing methods can be used to access Date and/or Time information from an OffsetDateTime: OffsetDateTime offsetDT9 = OffsetDateTime.parse("T08:20:45+07:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME) OffsetDateTime offsetDT8 = OffsetDateTime.parse("T15:20:30+08:00") OffsetDateTime offsetDT7 = OffsetDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()) OffsetDateTime offsetDT6 = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.of("+07:00")) OffsetDateTime offsetDT5 = OffsetDateTime.of(LocalDate.now(), LocalTime.of(15, 50, 25), ZoneOffset.of("+07:00")) OffsetDateTime offsetDT3 = OffsetDateTime.now(ZoneId.of("Asia/Jakarta")) OffsetDateTime offsetDT2 = OffsetDateTime.now(Clock.systemUTC()) OffsetDateTime offsetDT1 = OffsetDateTime.now() You can create a ZoneOffset object using the ZoneId.of(.) method. The time zone offsets are represented by the ZoneOffset class. static OffsetDateTime parse(CharSequence text, DateTimeFormatter formatter): Obtains an instance of OffsetDateTime from a text string using a specific formatter.

