List of utility methods to do LocalDateTime Format
LocalDateTime | convertDateStringToLocalDateTime(String formattedValue, int hour, int minute) Method that takes a string already preformatted to conform to preferred date format, and returns a LocalDateTime that corresponds to that date, at a specific hour and minute Objects.requireNonNull(formattedValue); if ((hour < 0 || hour > 24) || (minute < 0 || minute > 60)) { throw new IllegalArgumentException("Illegal argument! Hours and minutes must be in range 0-24, 0-60"); try { final LocalDate parsedDate = LocalDate.parse(formattedValue, preferredDateFormat); return LocalDateTime.of(parsedDate, LocalTime.of(hour, minute)); } catch (DateTimeParseException e) { ... |
String | convertTemporalToSplunkSearchFormat(OffsetDateTime localDateTime) convert Temporal To Splunk Search Format return TIME_SPLUNK_SEARCH_FORMATTER.format(localDateTime);
|
String | format(LocalDateTime dateTime) format if (dateTime == null) { return null; return dateTime.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)); |
String | format(LocalDateTime localDateTime, String pattern) format if (localDateTime == null) { return ""; return DateTimeFormatter.ofPattern(pattern == null ? DEFAULT_PATTERN : pattern).format(localDateTime); |
String | formatDate(LocalDateTime dateTime) format Date return dateTime.format(DateTimeFormatter.ofPattern("dd MMM yyyy")); |
String | formatDate(String inPattern, LocalDateTime inTime) format Date return formatDate(inPattern, Locale.getDefault(), inTime);
|
String | formatDateFromTo(LocalDateTime dateFrom, LocalDateTime dateTo) format Date From To if (dateFrom == null && dateTo == null) { return ""; } else if (dateTo == null) { return formatTime(dateFrom); } else if (dateFrom.isAfter(dateTo)) { return formatTime(dateFrom); } else if (dateFrom.toLocalDate().equals(dateTo.toLocalDate())) { return String.format("%s - %s", formatTime(dateFrom), formatTime(dateTo)); ... |
String | formatDateGeneric(DateTimeFormatter dateTimeFormatter, LocalDateTime localDateTime) format Date Generic return localDateTime == null || dateTimeFormatter == null ? "" : localDateTime.format(dateTimeFormatter); |
String | formatDateTime(LocalDateTime dateTime) Returns a string representing dateTime with DATE_TIME_FORMATTER return dateTime.format(DATE_TIME_FORMATTER);
|
String | formatDayOfMonth(LocalDateTime dateTime) format Day Of Month DateTimeFormatter formatter = DateTimeFormatter.ofPattern(FORMAT_DAY_OF_MONTH);
String formattedDateTime = dateTime.format(formatter);
return formattedDateTime + getDayNumberSuffix(Integer.valueOf(formattedDateTime));
|