List of utility methods to do DateTimeFormatter
Instant | fromInfluxDBTimeFormat(final String timestamp) from Influx DB Time Format return Instant.from(DateTimeFormatter.ISO_INSTANT.parse(timestamp));
|
Optional | fromString(String dateString, DateTimeFormatter formatter) from String if (dateString == null || formatter == null) return Optional.empty(); try { return Optional.of(ZonedDateTime.parse(dateString, formatter)); } catch (DateTimeParseException e) { return Optional.empty(); |
DateTimeFormatter | getDateFormat() get Date Format return DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"); |
DateTimeFormatter | getDateFormat(final Locale LOCALE) get Date Format if (Locale.US == LOCALE) { return DateTimeFormatter.ofPattern("MM/dd/YYYY"); } else if (Locale.CHINA == LOCALE) { return DateTimeFormatter.ofPattern("YYYY.MM.dd"); } else { return DateTimeFormatter.ofPattern("dd.MM.YYYY"); |
Date | getDateFromFormat(String dtStr) Expects date string as MM-dd-yyyy LocalDate ld = LocalDate.parse(dtStr, df2);
return localDateToSystemAdjustedStartOfDayDate(ld);
|
DateTimeFormatter | getDateTimeAttributeTimeFormat() Get a DateTimeFormatter to use for rendering time information within a time tag's datetime attribute return DateTimeFormatter.ofPattern("hh:mm a"); |
DateTimeFormatter | getDateTimeFormatter() Returns the date time formatter used to parse date strings. if (dateTimeTZFormat == null) { DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); DateTimeFormatter optionalTime = DateTimeFormatter.ofPattern(" HH:mm:ss"); DateTimeFormatter optionalSec = DateTimeFormatter.ofPattern(".SSS"); DateTimeFormatter optionalZone = DateTimeFormatter.ofPattern(" ZZZ"); dateTimeTZFormat = new DateTimeFormatterBuilder().append(dateFormatter).appendOptional(optionalTime) .appendOptional(optionalSec).appendOptional(optionalZone).toFormatter(); return dateTimeTZFormat; |
String | getFormatDate(String format) get Format Date return getFormatDate(format, new Date()); |
String | getFormattedDate() get Formatted Date return formatDate(getCurrentDate(), PATTERN_DEFAULT);
|
String | getFormattedDateString() get Formatted Date String LocalDateTime currentTime = LocalDateTime.now();
return currentTime.format(DateTimeFormatter.ISO_LOCAL_DATE);
|