Java Utililty Methods ZonedDateTime Calculate

List of utility methods to do ZonedDateTime Calculate

Description

The list of methods to do ZonedDateTime Calculate are organized into topic(s).

Method

ZonedDateTimegetStartOfWeek(ZoneId zoneId, ZonedDateTime time)
get Start Of Week
LocalDate date = getStartOfDay(zoneId, time).toLocalDate();
return getStartOfWeek(date).atStartOfDay(zoneId);
StringgetTime(ZonedDateTime zonedTime)
get Time
ZonedDateTime newYorkTime = zonedTime.withZoneSameInstant(ZoneId.of("America/New_York"));
return formatter.format(newYorkTime);
PathgetTimePath(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));
...
ZonedDateTimegetZonedDateTimeForComparison(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;
ListholidaysInRange(ZonedDateTime startDate, ZonedDateTime endDate, List holidays)
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);
booleanisBetweenTimesInclusive(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);
StringisoDateTime(ZonedDateTime zonedDateTime)
iso Date Time
return zonedDateTime.format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
ZonedDateTimemapToZonedDateTime(final Date date)
Converts a Date into a ZonedDateTime .
if (date == null) {
    return null;
return ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
ZonedDateTimemax(ZonedDateTime a, ZonedDateTime b)
max
return a.compareTo(b) > 0 ? a : b;
ZonedDateTimeoneDayLater(ZonedDateTime baseDate)
Shift base date by one day later.
return baseDate.plusDays(1);