List of utility methods to do ZonedDateTime Calculate
ZonedDateTime | getStartOfWeek(ZoneId zoneId, ZonedDateTime time) get Start Of Week LocalDate date = getStartOfDay(zoneId, time).toLocalDate();
return getStartOfWeek(date).atStartOfDay(zoneId);
|
String | getTime(ZonedDateTime zonedTime) get Time ZonedDateTime newYorkTime = zonedTime.withZoneSameInstant(ZoneId.of("America/New_York")); return formatter.format(newYorkTime); |
Path | getTimePath(Path dir, String ext, ZonedDateTime dateTime) get Time Path if (!ext.startsWith(".")) { ext = "." + ext; String pattern = "yyyyMMddHHmmss'" + ext + "'"; DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); builder.appendPattern(pattern); DateTimeFormatter formatter = builder.toFormatter(); return dir.resolve(dateTime.format(formatter)); ... |
ZonedDateTime | getZonedDateTimeForComparison(TimeZone zone) Get a ZonedDateTime for comparison on membership dates ZonedDateTime dt = ZonedDateTime.now(zone.toZoneId());
dt = dt.plus(1L, ChronoUnit.HOURS);
dt = dt.truncatedTo(ChronoUnit.HOURS);
return dt;
|
List | holidaysInRange(ZonedDateTime startDate, ZonedDateTime endDate, List holidays In Range if (holidays.isEmpty()) { return holidays; int idxstart = findIdx(0, holidays.size() - 1, startDate, holidays); int idxend = findIdx(0, holidays.size() - 1, endDate, holidays); return holidays.subList(idxstart, idxend + 1); |
boolean | isBetweenTimesInclusive(ZonedDateTime dateTime, ZonedDateTime startDateTime, ZonedDateTime endDateTime) is Between Times Inclusive if (dateTime == null) return true; if (startDateTime == null) { if (endDateTime == null) { return true; } else { return !dateTime.isAfter(endDateTime); } else { if (endDateTime == null) { return !dateTime.isBefore(startDateTime); } else { return !dateTime.isBefore(startDateTime) && !dateTime.isAfter(endDateTime); |
String | isoDateTime(ZonedDateTime zonedDateTime) iso Date Time return zonedDateTime.format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
|
ZonedDateTime | mapToZonedDateTime(final Date date) Converts a Date into a ZonedDateTime . if (date == null) { return null; return ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); |
ZonedDateTime | max(ZonedDateTime a, ZonedDateTime b) max return a.compareTo(b) > 0 ? a : b;
|
ZonedDateTime | oneDayLater(ZonedDateTime baseDate) Shift base date by one day later. return baseDate.plusDays(1);
|