List of utility methods to do LocalDateTime Format
String | formatLocalDateTimeToString(LocalDateTime date) Formats a LocalDateTime into a string return date.format(localDateTimeFormatter);
|
String | formatShortDate(LocalDateTime dateTime) format Short Date if (dateTime == null) { return null; LocalDate date = dateTime.toLocalDate(); long daysDifference = LocalDate.now().until(date, ChronoUnit.DAYS); String dateFormat; if (daysDifference >= 2 && daysDifference <= 6) { dateFormat = "dd MMM"; ... |
String | formattedWeek(LocalDateTime localDateTime) formatted Week return String.format("%04d-%02d", localDateTime.getYear(), localDateTime.get(WeekFields.of(Locale.getDefault()).weekOfWeekBasedYear())); |
String | formatTime(LocalDateTime dateTime) format Time DateTimeFormatter formatter = DateTimeFormatter.ofPattern(FORMAT_TIME);
return dateTime.format(formatter);
|
String | formatTime(LocalDateTime time) format Time return String.join(timeDelimiter, String.format("%02d", time.getHour()), String.format("%02d", time.getMinute()), String.format("%02d", time.getSecond())); |
String | localDateTime2Str(LocalDateTime localDateTime, String dateTimeFormatter) local Date Time Str return localDateTime.format(DateTimeFormatter.ofPattern(dateTimeFormatter));
|
String | toDoubleExcelFormat(LocalDateTime date, boolean date1904) to Double Excel Format if (date == null) return ""; LocalDateTime from; if (date1904) { from = LocalDateTime.of(1904, 1, 1, 0, 0, 0); } else { from = LocalDateTime.of(1900, 1, 1, 0, 0, 0); if (date.isBefore(LocalDateTime.of(1900, 3, 1, 0, 0, 0))) { ... |
LocalDateTime | toLocalDateTime(String date, DateTimeFormatter formatter) to Local Date Time try { ZonedDateTime zonedDateTime = toZonedDateTime(date, formatter); return LocalDateTime.ofInstant(zonedDateTime.toInstant(), ZoneId.systemDefault()); } catch (Exception e) { throw new IllegalArgumentException(e); |
String | toString(LocalDateTime ldt, DateTimeFormatter formatter) to String return ldt == null ? "" : ldt.format(formatter); |