List of utility methods to do DateTimeFormatter
LocalDateTime | formatDate(long timestamp) format Date return LocalDateTime.ofEpochSecond(timestamp / 1_000, 0, ZoneOffset.UTC);
|
String | formatDate(long timestamp) format Date return Instant.ofEpochMilli(timestamp).atZone(UTC_ZONE).format(DATE_PARSER_FORMATTER);
|
LocalDateTime | formatDateAndTime(String dateAndTime) Parses a String to a LocalDateTime object like for example to '2015-12-15 12:30'; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); LocalDateTime formatedDate = LocalDateTime.parse(dateAndTime, formatter); return formatedDate; |
String | formatDateTime(Date dateTime) Format a date/time to YYYY-MM-dd HH:mm:ss format return dateTimeFormatter.format(dateTime);
|
String | formatDateTime(long milis) format Date Time LocalDateTime dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(milis), ZoneId.systemDefault());
return DTF.format(dateTime);
|
String | formatISOUTCDateTime(long timestamp) format ISOUTC Date Time ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneOffset.UTC);
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
return formatter.format(zonedDateTime);
|
String | formatNow(String format) format Now DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
return utcNow().format(formatter);
|
String | formatTime(long milliSeconds) Formats a timestamp in a format suitable to be presented to the user using the current timezone. return formatTime(milliSeconds, currentZoneId);
|
String | formatTimestamp(long timestamp) format Timestamp return Instant.ofEpochMilli(timestamp).atZone(ZoneId.of("UTC")).toLocalDateTime() .format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")); |
String | formatTimestap(final long timestap) format Timestap return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, Locale.ENGLISH)
.format(Date.from(Instant.ofEpochMilli(timestap)));
|