Java Utililty Methods ZonedDateTime Format

List of utility methods to do ZonedDateTime Format

Description

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

Method

Stringformat(ZonedDateTime zdt, DateTimeFormatter dtf)
format
return zdt.format(dtf);
Stringformat(ZonedDateTime zonedDateTime)
format
return zonedDateTime.format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
StringformatDate(ZonedDateTime dateTime)
Format a ZonedDateTime as RFC 1123 date format used in HTTP.
return RFC_1123_DATE_TIME.format(dateTime.withZoneSameInstant(GMT));
StringformatDate(ZonedDateTime dt)
format Date
DateTimeFormatter fmt = DateTimeFormatter.ISO_OFFSET_DATE_TIME.withZone(ZoneOffset.UTC);
return fmt.format(dt.truncatedTo(ChronoUnit.SECONDS));
StringformatDate_ddMMYYYYHHmmss(ZonedDateTime now)
format Datdd MMYYYYH Hmmss
return now.format(dateTimeFormatPattern);
StringformatDateAsShortDateLocalTime(ZonedDateTime moonDate, ZoneId tz)
Useful date-to-string formatting which I found myself using a lot
return moonDate.withZoneSameInstant(tz).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
StringformatDateForGMT(ZonedDateTime moonDate)
Useful date-to-string formatting which I found myself using a lot
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return moonDate.withZoneSameInstant(ZoneOffset.UTC).format(df);
StringformatDateTime(ZonedDateTime zonedDateTime)
format Date Time
return DEFAULT_DATETIME_FORMATTER.format(zonedDateTime);
StringformatZonedDateTime(ZonedDateTime zonedDateTime)
format Zoned Date Time
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm zZ",
        Locale.getDefault());
return zonedDateTime.format(dateTimeFormatter.withZone(getZoneId()));
StringgetFormattedHour(ZonedDateTime dateTime)
get Formatted Hour
if (dateTime.getHour() < 10) {
    return "0" + dateTime.getHour();
return String.valueOf(dateTime.getHour());