public static DateUtilsFactory newFactory(ZoneId timeZone) { return new DateUtilsFactory(timeZone); }
public static LocalDate currentLocalDate() { return factory.currentLocalDate(); }
public static LocalDateTime currentLocalDateTime() { return factory.currentLocalDateTime(); }
public LocalTime toLocalTime(String date) { try { return LocalTime.parse(date); } catch (Exception ignored) {} if (date == null) { return null; } date = sanitize(date); if (date.contains("-") == false) { return LocalTime.parse(date); } else if (date.contains("T")) { LocalDateTime ldt = toLocalDateTime(date); return ldt.toLocalTime(); } else { return LocalTime.MIDNIGHT; } } public LocalTime toLocalTime(long date) {
public LocalDateTime toLocalDateTime(String date) { try { return LocalDateTime.parse(date); } catch (Exception ignored) {} if (date == null) { return null; } date = sanitize(date); if (date.contains("T") == false) { date = date + "T" + LocalTime.MIDNIGHT; } int pos = date.indexOf("T"); int zonePos = date.indexOf("-", pos); if (zonePos >= 0 || date.toUpperCase().endsWith("Z")) { return toZonedDateTime(date).toLocalDateTime(); } else { return LocalDateTime.parse(date); } }
public ZonedDateTime toZonedDateTime(String date) { try { return ZonedDateTime.parse(date); } catch (Exception ignored) {} if (date == null) { return null; } date = sanitize(date); int posT = date.indexOf("T"); if (posT >= 0) { int posZ = date.indexOf("-", posT); if (posZ >= 0) { String zone = date.substring(posZ); date = date.substring(0, posZ); date += zone; return ZonedDateTime.parse(date); } else if (date.toUpperCase().endsWith("Z")) { LocalDateTime localDateTime = LocalDateTime.parse(date, getFormatter(date)); ZoneId zoneId = ZoneId.of("Z"); ZonedDateTime value = ZonedDateTime.of(localDateTime, zoneId); return value; } else { LocalDateTime localDateTime = LocalDateTime.parse(date, getFormatter(date)); return ZonedDateTime.of(localDateTime, zoneId); } } else { LocalDate localDate = LocalDate.parse(date, getFormatter(date)); return ZonedDateTime.of(localDate, LocalTime.MIDNIGHT, zoneId); } }
public static String toAbbreviatedMonth(Month month) { return factory.toAbbreviatedMonth(month); } public static String toAbbreviatedMonth(YearMonth yearMonth) {
public static LocalDateTime toFirstDate(LocalDateTime date) { return factory.toFirstDate(date); } public static ZonedDateTime toFirstDate(ZonedDateTime date) {
public static LocalDate toLastDate(LocalDate date) { return factory.toLastDate(date); } public static LocalDateTime toLastDate(LocalDateTime date) {
public static LocalTime currentLocalTime() { return factory.currentLocalTime(); }
public static ZonedDateTime currentZonedDateTime() { return factory.currentZonedDateTime(); }
public LocalDate toLocalDate(String date) { try { return LocalDate.parse(date); } catch (Exception ignored) {} if (StringUtils.isBlank(date)) { return null; } date = sanitize(date); if (date.contains("T")) { date = date.substring(0, date.indexOf('T')); return LocalDate.parse(date); } else { return LocalDate.parse(date); } } public LocalDate toLocalDate(long date) {
public static String toAbbreviatedMonth(YearMonth yearMonth) { return factory.toAbbreviatedMonth(yearMonth); } public static String toAbbreviatedMonth(int month) {
public static LocalDate toFirstDate(LocalDate date) { return factory.toFirstDate(date); } public static LocalDateTime toFirstDate(LocalDateTime date) {
public static LocalDateTime toLastDate(LocalDateTime date) { return factory.toLastDate(date); } public static ZonedDateTime toLastDate(ZonedDateTime date) {
@Deprecated public static LocalTime currentTime() { return factory.currentLocalTime(); } public static LocalTime currentLocalTime() {
public static String toAbbreviatedMonth(int month) { return factory.toAbbreviatedMonth(month); }
public static ZonedDateTime toFirstDate(ZonedDateTime date) { return factory.toFirstDate(date); }
public static ZonedDateTime toLastDate(ZonedDateTime date) { return factory.toLastDate(date); }
@Deprecated public static LocalDateTime currentDateTime() { return factory.currentLocalDateTime(); } public static LocalDateTime currentLocalDateTime() {