public class DateFormatter extends Object
Thread-safe. Faster than normal formatter. - DateTimeFormatter is immutable and thread-safe. - DateFormat is not thread-safe. see threadlocal-memory-leak-in-java-web see threadlocal-memory-leak
| Modifier | Constructor and Description |
|---|---|
protected |
DateFormatter() |
| Modifier and Type | Method and Description |
|---|---|
static @NotNull String |
date10(@Nullable Date date)
Format to yyyy-MM-dd.
|
static @NotNull String |
date10(@Nullable Date date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd at zoneId.
|
static @NotNull String |
date10(@Nullable LocalDate date)
Format to yyyy-MM-dd.
|
static @NotNull String |
date10(@Nullable LocalDateTime date)
Format to yyyy-MM-dd.
|
static @NotNull String |
date10(@Nullable ZonedDateTime date)
Format to yyyy-MM-dd.
|
static @NotNull String |
date10(@Nullable ZonedDateTime date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd at zoneId.
|
static @NotNull String |
fixFull19(@Nullable String date)
Guarantee consistency, i.e.
|
static @NotNull String |
full(@Nullable Date date)
Format to yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss.SSS.
|
static @NotNull String |
full(@Nullable Date date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss.SSS at zoneId.
|
static @NotNull String |
full(@Nullable LocalDateTime date)
Format to yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss.SSS.
|
static @NotNull String |
full(@Nullable ZonedDateTime date)
Format to yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss.SSS.
|
static @NotNull String |
full(@Nullable ZonedDateTime date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd HH:mm:ss or yyyy-MM-dd HH:mm:ss.SSS at zoneId.
|
static DateFormat |
full19() |
static @NotNull String |
full19(@Nullable Date date)
Format to yyyy-MM-dd HH:mm:ss.
|
static @NotNull String |
full19(@Nullable Date date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd HH:mm:ss at zoneId.
|
static @NotNull String |
full19(@Nullable LocalDateTime date)
Format to yyyy-MM-dd HH:mm:ss.
|
static @NotNull String |
full19(@Nullable ZonedDateTime date)
Format to yyyy-MM-dd HH:mm:ss.
|
static @NotNull String |
full19(@Nullable ZonedDateTime date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd HH:mm:ss at zoneId.
|
static DateFormat |
full23() |
static @NotNull String |
full23(@Nullable Date date)
Format to yyyy-MM-dd HH:mm:ss.SSS.
|
static @NotNull String |
full23(@Nullable Date date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd HH:mm:ss.SSS at zoneId.
|
static @NotNull String |
full23(@Nullable LocalDateTime date)
Format to yyyy-MM-dd HH:mm:ss.SSS.
|
static @NotNull String |
full23(@Nullable ZonedDateTime date)
Format to yyyy-MM-dd HH:mm:ss.SSS.
|
static @NotNull String |
full23(@Nullable ZonedDateTime date,
@Nullable ZoneId zoneId)
Format to yyyy-MM-dd HH:mm:ss.SSS at zoneId.
|
static @NotNull String |
fullTz(@Nullable OffsetDateTime date) |
static @NotNull String |
fullTz(@Nullable ZonedDateTime date) |
static @NotNull String |
time(@Nullable Date date)
Format to HH:mm:ss or HH:mm:ss.SSS.
|
static @NotNull String |
time(@Nullable Date date,
@Nullable ZoneId zoneId)
Format to HH:mm:ss or HH:mm:ss.SSS at zoneId.
|
static @NotNull String |
time(@Nullable LocalDateTime date)
Format to HH:mm:ss or HH:mm:ss.SSS.
|
static @NotNull String |
time(@Nullable LocalTime time)
Format to HH:mm:ss or HH:mm:ss.SSS.
|
static @NotNull String |
time(@Nullable ZonedDateTime date)
Format to HH:mm:ss or HH:mm:ss.SSS.
|
static @NotNull String |
time(@Nullable ZonedDateTime date,
@Nullable ZoneId zoneId)
Format to HH:mm:ss or HH:mm:ss.SSS at zoneId.
|
static @NotNull String |
time08(@Nullable Date date)
Format to HH:mm:ss.
|
static @NotNull String |
time08(@Nullable Date date,
@Nullable ZoneId zoneId)
Format to HH:mm:ss at zoneId.
|
static @NotNull String |
time08(@Nullable LocalDateTime date)
Format to HH:mm:ss.
|
static @NotNull String |
time08(@Nullable LocalTime time)
Format to HH:mm:ss.
|
static @NotNull String |
time08(@Nullable ZonedDateTime date)
Format to HH:mm:ss.
|
static @NotNull String |
time08(@Nullable ZonedDateTime date,
@Nullable ZoneId zoneId)
Format to HH:mm:ss at zoneId.
|
static @NotNull String |
time12(@Nullable Date date)
Format to HH:mm:ss.SSS.
|
static @NotNull String |
time12(@Nullable Date date,
@Nullable ZoneId zoneId)
Format to HH:mm:ss.SSS at zoneId.
|
static @NotNull String |
time12(@Nullable LocalDateTime date)
Format to HH:mm:ss.SSS.
|
static @NotNull String |
time12(@Nullable LocalTime time)
Format to HH:mm:ss.SSS.
|
static @NotNull String |
time12(@Nullable ZonedDateTime date)
Format to HH:mm:ss.SSS.
|
static @NotNull String |
time12(@Nullable ZonedDateTime date,
@Nullable ZoneId zoneId)
Format to HH:mm:ss.SSS at zoneId.
|
static @NotNull ZonedDateTime |
zoned(@NotNull Date date,
@Nullable ZoneId zoneId)
convert date at zoneId
|
public static final String PTN_DATE_10
public static final String PTN_TIME_08
public static final String PTN_TIME_12
public static final String PTN_FULL_19
public static final String PTN_FULL_23
public static final String PTN_FULL_TZ
public static final String PTN_FULL_OZ
public static final String PTN_TIME_PSE
public static final String PTN_DATE_PSE
public static final String PTN_FULL_PSE
public static final String PTN_ZONE_PSE
public static final String PTN_DATE_PSE_US
public static final String PTN_FULL_PSE_US
public static final String PTN_ZONE_PSE_US
public static final DateTimeFormatter FMT_DATE_10
public static final DateTimeFormatter FMT_TIME_08
public static final DateTimeFormatter FMT_TIME_12
public static final DateTimeFormatter FMT_FULL_19
public static final DateTimeFormatter FMT_FULL_23
public static final DateTimeFormatter FMT_TIME_PSE
public static final DateTimeFormatter FMT_DATE_PSE
public static final DateTimeFormatter FMT_FULL_PSE
public static final DateTimeFormatter FMT_ZONE_PSE
public static final DateTimeFormatter FMT_DATE_PSE_US
public static final DateTimeFormatter FMT_FULL_PSE_US
public static final DateTimeFormatter FMT_ZONE_PSE_US
public static final DateTimeFormatter FMT_FULL_TZ
public static final DateTimeFormatter FMT_FULL_OZ
public static final ThreadLocal<DateFormat> DATE_FORMAT_19
public static final ThreadLocal<DateFormat> DATE_FORMAT_23
public static DateFormat full19()
public static DateFormat full23()
@NotNull public static @NotNull String fullTz(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String fullTz(@Nullable @Nullable OffsetDateTime date)
@NotNull public static @NotNull String date10(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String full(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String full19(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String full23(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String time(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String time08(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String time12(@Nullable @Nullable ZonedDateTime date)
@NotNull public static @NotNull String date10(@Nullable @Nullable ZonedDateTime date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String full(@Nullable @Nullable ZonedDateTime date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String full19(@Nullable @Nullable ZonedDateTime date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String full23(@Nullable @Nullable ZonedDateTime date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String time(@Nullable @Nullable ZonedDateTime date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String time08(@Nullable @Nullable ZonedDateTime date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String time12(@Nullable @Nullable ZonedDateTime date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String date10(@Nullable @Nullable LocalDateTime date)
@NotNull public static @NotNull String full(@Nullable @Nullable LocalDateTime date)
@NotNull public static @NotNull String full19(@Nullable @Nullable LocalDateTime date)
@NotNull public static @NotNull String full23(@Nullable @Nullable LocalDateTime date)
@NotNull public static @NotNull String time(@Nullable @Nullable LocalDateTime date)
@NotNull public static @NotNull String time08(@Nullable @Nullable LocalDateTime date)
@NotNull public static @NotNull String time12(@Nullable @Nullable LocalDateTime date)
@NotNull public static @NotNull String date10(@Nullable @Nullable LocalDate date)
@NotNull public static @NotNull String time(@Nullable @Nullable LocalTime time)
@NotNull public static @NotNull String time08(@Nullable @Nullable LocalTime time)
@NotNull public static @NotNull String time12(@Nullable @Nullable LocalTime time)
@NotNull public static @NotNull String date10(@Nullable @Nullable Date date)
@NotNull public static @NotNull String full(@Nullable @Nullable Date date)
@NotNull public static @NotNull String full19(@Nullable @Nullable Date date)
@NotNull public static @NotNull String full23(@Nullable @Nullable Date date)
@NotNull public static @NotNull String time(@Nullable @Nullable Date date)
@NotNull public static @NotNull String time08(@Nullable @Nullable Date date)
@NotNull public static @NotNull String time12(@Nullable @Nullable Date date)
@NotNull public static @NotNull String date10(@Nullable @Nullable Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String full(@Nullable @Nullable Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String full19(@Nullable @Nullable Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String full23(@Nullable @Nullable Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String time(@Nullable @Nullable Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String time08(@Nullable @Nullable Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String time12(@Nullable @Nullable Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull ZonedDateTime zoned(@NotNull @NotNull Date date, @Nullable @Nullable ZoneId zoneId)
@NotNull public static @NotNull String fixFull19(@Nullable @Nullable String date)
Guarantee consistency, i.e. the same string, returns consistent results. Fix date string to yyyy-MM-dd HH:mm:ss `HH`, `MM`, `ss` are pseudo-randomly generated based on `yyyy-MM-dd`, which defaults to `1979-01-01`, respectively.
date - Any date containing numbers, will automatically fix the hours, minutes and seconds.Copyright © 2023. All rights reserved.