List of utility methods to do OffsetDateTime
OffsetDateTime | nowAtZone(String offsetId) now At Zone return nowAtZone(ZoneOffset.of(offsetId));
|
Date | parseDate(String raw) parse Date return Date.from(OffsetDateTime.parse(fixOffset(raw)).toInstant());
|
String | stringifyDate(long timestamp) stringify Date return stringifyDate( OffsetDateTime.ofInstant(Instant.ofEpochMilli(timestamp), TimeZone.getTimeZone("GMT").toZoneId())); |
String | timeF(OffsetDateTime time, ZoneId zone) time F return time.atZoneSameInstant(zone).format(DateTimeFormatter.ISO_LOCAL_TIME).substring(0, 8);
|
Calendar | toCalendar(OffsetDateTime offsetDateTime) Convert the given OffsetDateTime instance to Calendar instance with the same time and time zone Objects.requireNonNull(offsetDateTime, "Offset date time is required"); TimeZone timeZone = TimeZone.getTimeZone(offsetDateTime.toZonedDateTime().getZone()); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(offsetDateTime.toInstant().toEpochMilli()); calendar.setTimeZone(timeZone); return calendar; |
String | toRfc1123String(FileTime time) to Rfc String final Temporal date = OffsetDateTime.ofInstant(time.toInstant(), ZoneOffset.UTC); return DateTimeFormatter.RFC_1123_DATE_TIME.format(date); |