Java Utililty Methods LocalDateTime to

List of utility methods to do LocalDateTime to

Description

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

Method

DatetoDate(LocalDateTime dateTime)
to Date
return Date.from(dateTime.toInstant(ZoneOffset.UTC));
DatetoDate(LocalDateTime ldt)
to Date
ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault());
GregorianCalendar cal = GregorianCalendar.from(zdt);
return cal.getTime();
StringtoDateHeader(LocalDateTime dt)
to Date Header
return String.format("%s, %02d %s %d %s GMT",
        dt.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.ENGLISH), dt.getDayOfMonth(),
        dt.getMonth().getDisplayName(TextStyle.SHORT, Locale.ENGLISH), dt.getYear(), dt.toLocalTime());
DatetoDateUTCFromJST(LocalDateTime dateTime)
to Date UTC From JST
if (dateTime == null) {
    return null;
ZonedDateTime zonedDateTime = dateTime.atZone(ZONEID_JST);
return Date.from(zonedDateTime.toInstant());
LocalDateTimetoJava8(org.joda.time.LocalDateTime x)
to Java
if (x == null)
    return null;
return toLocalDateTime(x.toDate().getTime());
StringtoJsonDate(LocalDateTime date)
Generate a JSON-formatted date string for a given date
return jsonFormatter.format(date);
booleantokenExpired(LocalDateTime expiryDate)
token Expired
return expiryDate.isBefore(LocalDateTime.now());
longtoMinuteCount(LocalDateTime ldt)
to Minute Count
return ldt.toInstant(OFFSET).getEpochSecond() / 60;
StringtoString(LocalDateTime time)
to String
return toString(time, "yyyy/MM/dd HH:mm:ss");
StringtoStringIfPresent(LocalDateTime dateTime)
to String If Present
if (dateTime != null) {
    return dateTime.toString();
} else {
    return null;