Java Utililty Methods Instant Format

List of utility methods to do Instant Format

Description

The list of methods to do Instant Format are organized into topic(s).

Method

Stringformat(Instant _instant, String _format)
Return a string from Instant using format _format
DateTimeFormatter format = DateTimeFormatter.ofPattern(_format);
try {
    return LocalDateTime.ofInstant(_instant, localZoneOffset).format(format);
} catch (DateTimeException exc) {
    System.out.printf("%s can't be formatted with pattern!%n", _instant, _format);
    throw exc;
Stringformat(Instant instant)
format
return outputDateFormat.format(instant);
StringformatAtSAST(Instant instant, DateTimeFormatter format)
format At SAST
return instant.atZone(zoneSAST).format(format);
StringformatDate(Instant date, Locale locale)
format Date
return null;
StringformatDateForInstant(Instant instant)
format Date For Instant
try {
    LocalDateTime localDate = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy");
    return localDate.format(formatter);
} catch (DateTimeException ignored) {
    return "N/A";
StringformatHttpDate(Instant instant)
format Http Date
return DateTimeFormatter.RFC_1123_DATE_TIME.format(instant.atOffset(ZoneOffset.UTC));
StringformatInstant(TemporalAccessor instant)
Formats the given instant to ISO8601 format including at least 3 positions for milliseconds.
return ISO_UTC_DATE_TIME.format(instant);
StringformatIso8601Date(Instant date)
Formats the specified date as an ISO 8601 string.
return ISO_INSTANT.format(date);
StringformatTimeLocal(Instant instant)
Returns the instant formatted as only time using the local timezone.
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT)
        .withZone(ZoneId.systemDefault());
return formatter.format(instant);
InstantparseInstant(String dateString, DateTimeFormatter formatter)
parse Instant
return formatter.withZone(ZoneOffset.UTC).parse(dateString, Instant::from);