Java Utililty Methods LocalDateTime Calculate

List of utility methods to do LocalDateTime Calculate

Description

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

Method

booleanshouldSend(Optional emailSentOpt, int timeToWait)
should Send
if (emailSentOpt.isPresent()) {
    long lastEmailSent = emailSentOpt.get().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
    long now = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
    return timeToWait < Math.abs(lastEmailSent - now);
return true;
voidsleepUntil(LocalDateTime next)
sleep Until
while (true) {
    try {
        LocalDateTime now = LocalDateTime.now();
        long intervalInMillis = now.until(next, ChronoUnit.MILLIS);
        if (intervalInMillis > 0) {
            Thread.sleep(intervalInMillis);
        return;
...
CalendartoCalendar(final LocalDateTime localDateTime)
Converts local date time to Calendar.
return GregorianCalendar.from(ZonedDateTime.of(localDateTime, ZoneId.systemDefault()));
OffsetDateTimetoOffsetDateTime(Date localDateTime, TimeZone clientTimeZone)
Converts the given local server time to the given TimeZone .
Objects.requireNonNull(localDateTime, "Local time is required");
Objects.requireNonNull(clientTimeZone, "Time zone is required");
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(localDateTime.getTime()), ZoneId.systemDefault())
        .withZoneSameInstant(clientTimeZone.toZoneId()).toOffsetDateTime();
LocalDateTimeWizzAirDatetimeCorrection(LocalDateTime aLocalDateTime)
Wizz Air Datetime Correction
ZonedDateTime lZDT = aLocalDateTime.atZone(ZoneId.of("Europe/Budapest"));
ZoneOffset lZO = lZDT.getOffset();
String lZId = lZO.getId();
Pattern reg = Pattern.compile("(\\+|-)(\\d{2})\\:(\\d{2})");
Matcher m = reg.matcher(lZId);
if (m.find()) {
    String lPrefix = m.group(1).toString().trim();
    String lHours = m.group(2).toString().trim();
...