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

DateparseZdtToDate(ZonedDateTime zdt)
parse Zdt To Date
return Date.from(zdt.toInstant());
ZonedDateTimeparseZonedDateTime(String zonedDateTimeString, String variableName)
parse Zoned Date Time
if (zonedDateTimeString == null)
    throw new IllegalArgumentException(variableName + " must not be null");
try {
    return ZonedDateTime.parse(zonedDateTimeString).truncatedTo(ChronoUnit.SECONDS);
} catch (DateTimeParseException e) {
    throw new IllegalArgumentException(variableName + " could not be parsed: " + e.getMessage());
StringpreProcess(String Val, ZonedDateTime BaseTimeMarker)
If the string passed in is not null and of exactly 16 characters in the form of "(+|-)(\d{2})y(\d{2})m(\d{2})d\s([01][0-9]|2[0-4])\:([0-5][0-9])", will return a JSON text representation of the baseTimeMarker with the delta specified by the pattern.
if (Val == null || Val.length() != 16)
    return Val;
Matcher M = _DELTA_DATETIME.matcher(Val);
if (M.matches() == false)
    return Val;
boolean Plus = M.group(1).equals("+");
int years = Integer.parseInt(M.group(2));
int months = Integer.parseInt(M.group(3));
...
StringprintDateTimeCompact(ZonedDateTime ZDT, boolean PrintTime, boolean PrintSeconds)
print Date Time Compact
return ZDT == null ? "NA"
        : ZDT.format(PrintTime == true ? PrintSeconds == true ? CompactFormaterTimeSec : CompactFormaterTime
                : CompactFormater);
StringprintDateTimeSuperCompact(ZonedDateTime ZDT)
print Date Time Super Compact
return ZDT == null ? "NA" : ZDT.format(SuperCompactFormater);
ZonedDateTimeroundTimeMinQuarter(ZonedDateTime dateTime)
Round the date time in argument to the nearest quarter (e.g.
int unroundedSec = dateTime.getSecond();
if (unroundedSec >= 30)
    dateTime = dateTime.plusMinutes(1);
dateTime = dateTime.truncatedTo(ChronoUnit.MINUTES);
int unroundedMin = dateTime.getMinute();
int div = unroundedMin / 15;
int mod = unroundedMin % 15;
if (mod >= 8)
...
ZonedDateTimeroundUp(ZonedDateTime date)
round Up
ChronoField field = ChronoField.NANO_OF_DAY;
return date.with(field, field.range().getMaximum());
intsecondsSinceMidnight(ZonedDateTime ZDT)
seconds Since Midnight
return ZDT.getHour() * 60 * 60 + ZDT.getMinute() * 60 + ZDT.getSecond();
StringsimplifyZonedDateTime(ZonedDateTime now, long timeToWait)
simplify Zoned Date Time
return now.plusSeconds(timeToWait).format(DateTimeFormatter.ofPattern("HH:mm:ss"));
ZonedDateTimestringToZonedDateTimeUTC(String dateAsString)
string To Zoned Date Time UTC
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_TIME_PATERN, Locale.ENGLISH);
LocalDateTime localDateTime = LocalDateTime.parse(dateAsString, formatter);
return localDateTime.atZone(ZoneOffset.UTC);