Package com.alibaba.fastjson2.util
Class DateUtils
- java.lang.Object
-
- com.alibaba.fastjson2.util.DateUtils
-
public class DateUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDateUtils.DateTimeFormatPattern
-
Field Summary
Fields Modifier and Type Field Description static ZoneIdDEFAULT_ZONE_IDstatic LocalDateLOCAL_DATE_19700101static ZoneIdOFFSET_8_ZONE_IDstatic StringOFFSET_8_ZONE_ID_NAMEstatic ZoneIdSHANGHAI_ZONE_IDstatic StringSHANGHAI_ZONE_ID_NAMEstatic ZoneRulesSHANGHAI_ZONE_RULES
-
Constructor Summary
Constructors Constructor Description DateUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringformat(int year, int month, int dayOfMonth)static Stringformat(int year, int month, int dayOfMonth, int hour, int minute, int second)static Stringformat(int year, int month, int dayOfMonth, DateUtils.DateTimeFormatPattern pattern)static Stringformat(long timeMillis)static Stringformat(long timeMillis, DateUtils.DateTimeFormatPattern pattern)static Stringformat(LocalDate localDate, String format)static Stringformat(LocalDateTime ldt, String format)static Stringformat(ZonedDateTime zdt, String format)static Stringformat(Date date)static Stringformat(Date date, String format)static StringformatYMD10(int year, int month, int dayOfMonth)static StringformatYMD10(long timeMillis, ZoneId zoneId)static StringformatYMD10(LocalDate date)static StringformatYMD10(Date date)static StringformatYMD8(long timeMillis, ZoneId zoneId)static StringformatYMD8(LocalDate date)static StringformatYMD8(Date date)static StringformatYMDHMS19(LocalDate localDate)static StringformatYMDHMS19(LocalDateTime ldt)static StringformatYMDHMS19(ZonedDateTime zdt)static StringformatYMDHMS19(Date date)static StringformatYMDHMS19(Date date, ZoneId zoneId)static intgetShanghaiZoneOffsetTotalSeconds(long seconds)static ZoneIdgetZoneId(String zoneIdStr, ZoneId defaultZoneId)static inthourAfterNoon(char h0, char h1)static booleanisDate(String str)static booleanisLocalDate(String str)static booleanisLocalTime(String str)static LocalDateTimelocalDateTime(char y0, char y1, char y2, char y3, char m0, char m1, char d0, char d1, char h0, char h1, char i0, char i1, char s0, char s1)static LocalDateTimelocalDateTime(char y0, char y1, char y2, char y3, char m0, char m1, char d0, char d1, char h0, char h1, char i0, char i1, char s0, char s1, char S0, char S1, char S2, char S3, char S4, char S5, char S6, char S7, char S8)static longmillis(LocalDateTime ldt)static longmillis(LocalDateTime ldt, ZoneId zoneId)static longmillis(ZoneId zoneId, int year, int month, int dom, int hour, int minute, int second, int nanoOfSecond)static intmonth(char c0, char c1, char c2)static DateparseDate(String str)static DateparseDate(String str, String format)static DateparseDate(String str, String format, ZoneId zoneId)static DateparseDate(String str, ZoneId zoneId)static DateparseDateYMDHMS19(String str)static LocalDateparseLocalDate(byte[] str, int off, int len)static LocalDateparseLocalDate(char[] str, int off, int len)static LocalDateparseLocalDate(String str)static LocalDateparseLocalDate10(byte[] str, int off)yyyy-MM-dd yyyy/MM/dd MM/dd/yyyy dd.MM.yyyy yyyy年M月dd日 yyyy年MM月d日 yyyy MMM dstatic LocalDateparseLocalDate10(char[] str, int off)yyyy-MM-dd yyyy/MM/dd MM/dd/yyyy dd.MM.yyyy yyyy年M月dd日 yyyy年MM月d日 yyyy MMM dstatic LocalDateparseLocalDate11(byte[] str, int off)static LocalDateparseLocalDate11(char[] str, int off)yyyy年MM月dd日 yyyy년MM월dd일static LocalDateparseLocalDate8(byte[] str, int off)yyyy-m-d yyyyMMdd d-MMM-yystatic LocalDateparseLocalDate8(char[] str, int off)yyyy-m-d yyyyMMdd d-MMM-yystatic LocalDateparseLocalDate9(byte[] str, int off)yyyy-MM-d yyyy-M-dd dd-MMM-yystatic LocalDateparseLocalDate9(char[] str, int off)yyyy-MM-d yyyy-M-dd dd-MMM-yystatic LocalDateTimeparseLocalDateTime(byte[] str, int off, int len)static LocalDateTimeparseLocalDateTime(char[] str, int off, int len)static LocalDateTimeparseLocalDateTime(String str)static LocalDateTimeparseLocalDateTime(String str, int off, int len)static LocalDateTimeparseLocalDateTime12(byte[] str, int off)parseLocalDateTime use format 'yyyyMMddHHmm'static LocalDateTimeparseLocalDateTime12(char[] str, int off)static LocalDateTimeparseLocalDateTime14(byte[] str, int off)yyyyMMddHHmmssstatic LocalDateTimeparseLocalDateTime14(char[] str, int off)yyyyMMddHHmmssstatic LocalDateTimeparseLocalDateTime16(byte[] str, int off)yyyy-MM-ddTHH:mm yyyy-MM-dd HH:mm yyyyMMddTHHmmssZ yyyy-MM-ddTH:m:s yyyy-MM-dd H:m:sstatic LocalDateTimeparseLocalDateTime16(char[] str, int off)yyyy-MM-ddTHH:mm yyyy-MM-dd HH:mm yyyyMMddTHHmmssZ yyyy-MM-ddTH:m:s yyyy-MM-dd H:m:sstatic LocalDateTimeparseLocalDateTime17(byte[] str, int off)yyyy-MM-ddTHH:mmZ yyyy-MM-dd HH:mmZ yyyy-M-dTHH:mm:ss yyyy-M-d HH:mm:ssstatic LocalDateTimeparseLocalDateTime17(char[] str, int off)yyyy-MM-ddTHH:mmZ yyyy-MM-dd HH:mmZ yyyy-M-dTHH:mm:ss yyyy-M-d HH:mm:ssstatic LocalDateTimeparseLocalDateTime18(byte[] str, int off)yyyy-M-ddTHH:mm:ss yyyy-M-dd HH:mm:ss yyyy-MM-dTHH:mm:ss yyyy-MM-d HH:mm:ss yyyy-MM-ddTH:mm:ss yyyy-MM-dd H:mm:ss yyyy-MM-ddTHH:m:ss yyyy-MM-dd HH:m:ss yyyy-MM-ddTHH:mm:s yyyy-MM-dd HH:mm:sstatic LocalDateTimeparseLocalDateTime18(char[] str, int off)yyyy-M-ddTHH:mm:ss yyyy-M-dd HH:mm:ss yyyy-MM-dTHH:mm:ss yyyy-MM-d HH:mm:ss yyyy-MM-ddTH:mm:ss yyyy-MM-dd H:mm:ss yyyy-MM-ddTHH:m:ss yyyy-MM-dd HH:m:ss yyyy-MM-ddTHH:mm:s yyyy-MM-dd HH:mm:sstatic LocalDateTimeparseLocalDateTime19(byte[] str, int off)yyyy-MM-ddTHH:mm:ss yyyy-MM-dd HH:mm:ss yyyy/MM/ddTHH:mm:ss yyyy/MM/dd HH:mm:ssstatic LocalDateTimeparseLocalDateTime19(char[] str, int off)yyyy-MM-ddTHH:mm:ss yyyy-MM-dd HH:mm:ss yyyy/MM/ddTHH:mm:ss yyyy/MM/dd HH:mm:ssstatic LocalDateTimeparseLocalDateTime19(String str, int off)static LocalDateTimeparseLocalDateTime20(byte[] str, int off)static LocalDateTimeparseLocalDateTime20(char[] str, int off)static LocalDateTimeparseLocalDateTime26(byte[] str, int off)static LocalDateTimeparseLocalDateTime26(char[] str, int off)static LocalDateTimeparseLocalDateTime27(byte[] str, int off)static LocalDateTimeparseLocalDateTime27(char[] str, int off)static LocalDateTimeparseLocalDateTime28(byte[] str, int off)static LocalDateTimeparseLocalDateTime28(char[] str, int off)static LocalDateTimeparseLocalDateTime29(byte[] str, int off)static LocalDateTimeparseLocalDateTime29(char[] str, int off)static LocalDateTimeparseLocalDateTimeX(byte[] str, int offset, int len)static LocalDateTimeparseLocalDateTimeX(char[] str, int offset, int len)static LocalTimeparseLocalTime(char c0, char c1, char c2, char c3, char c4, char c5, char c6, char c7)static LocalTimeparseLocalTime10(byte[] bytes, int off)static LocalTimeparseLocalTime10(char[] bytes, int off)static LocalTimeparseLocalTime11(byte[] bytes, int off)static LocalTimeparseLocalTime11(char[] bytes, int off)static LocalTimeparseLocalTime12(byte[] bytes, int off)static LocalTimeparseLocalTime12(char[] bytes, int off)static LocalTimeparseLocalTime18(byte[] bytes, int off)static LocalTimeparseLocalTime18(char[] bytes, int off)static LocalTimeparseLocalTime5(byte[] bytes, int off)static LocalTimeparseLocalTime5(char[] chars, int off)static LocalTimeparseLocalTime6(byte[] bytes, int off)static LocalTimeparseLocalTime6(char[] chars, int off)static LocalTimeparseLocalTime7(byte[] bytes, int off)static LocalTimeparseLocalTime7(char[] chars, int off)static LocalTimeparseLocalTime8(byte[] bytes, int off)static LocalTimeparseLocalTime8(char[] bytes, int off)static longparseMillis(byte[] bytes, int off, int len)static longparseMillis(byte[] bytes, int off, int len, Charset charset)static longparseMillis(byte[] chars, int off, int len, Charset charset, ZoneId zoneId)static longparseMillis(char[] bytes, int off, int len)static longparseMillis(char[] chars, int off, int len, ZoneId zoneId)static longparseMillis(String str)static longparseMillis(String str, ZoneId zoneId)static longparseMillis19(byte[] bytes, int off, ZoneId zoneId)static longparseMillis19(char[] bytes, int off, ZoneId zoneId)static longparseMillis19(String str, ZoneId zoneId)static longparseMillisYMDHMS19(String str, ZoneId zoneId)static ZonedDateTimeparseZonedDateTime(byte[] str, int off, int len)static ZonedDateTimeparseZonedDateTime(byte[] str, int off, int len, ZoneId defaultZoneId)static ZonedDateTimeparseZonedDateTime(char[] str, int off, int len)static ZonedDateTimeparseZonedDateTime(char[] str, int off, int len, ZoneId defaultZoneId)static ZonedDateTimeparseZonedDateTime(String str)static ZonedDateTimeparseZonedDateTime(String str, ZoneId defaultZoneId)static intreadNanos(byte[] bytes, int len, int offset)static intreadNanos(char[] chars, int len, int offset)static StringtoString(long timeMillis, boolean timeZone, ZoneId zoneId)static StringtoString(Date date)static longutcSeconds(int year, int month, int dom, int hour, int minute, int second)
-
-
-
Field Detail
-
DEFAULT_ZONE_ID
public static final ZoneId DEFAULT_ZONE_ID
-
SHANGHAI_ZONE_ID_NAME
public static final String SHANGHAI_ZONE_ID_NAME
- See Also:
- Constant Field Values
-
SHANGHAI_ZONE_ID
public static final ZoneId SHANGHAI_ZONE_ID
-
SHANGHAI_ZONE_RULES
public static final ZoneRules SHANGHAI_ZONE_RULES
-
OFFSET_8_ZONE_ID_NAME
public static final String OFFSET_8_ZONE_ID_NAME
- See Also:
- Constant Field Values
-
OFFSET_8_ZONE_ID
public static final ZoneId OFFSET_8_ZONE_ID
-
LOCAL_DATE_19700101
public static final LocalDate LOCAL_DATE_19700101
-
-
Method Detail
-
parseMillis
public static long parseMillis(String str)
-
parseLocalDateTime
public static LocalDateTime parseLocalDateTime(String str)
-
parseLocalDateTime
public static LocalDateTime parseLocalDateTime(String str, int off, int len)
-
parseLocalDateTime
public static LocalDateTime parseLocalDateTime(char[] str, int off, int len)
-
parseLocalTime5
public static LocalTime parseLocalTime5(byte[] bytes, int off)
-
parseLocalTime5
public static LocalTime parseLocalTime5(char[] chars, int off)
-
parseLocalTime6
public static LocalTime parseLocalTime6(byte[] bytes, int off)
-
parseLocalTime6
public static LocalTime parseLocalTime6(char[] chars, int off)
-
parseLocalTime7
public static LocalTime parseLocalTime7(byte[] bytes, int off)
-
parseLocalTime7
public static LocalTime parseLocalTime7(char[] chars, int off)
-
parseLocalTime8
public static LocalTime parseLocalTime8(byte[] bytes, int off)
-
parseLocalTime8
public static LocalTime parseLocalTime8(char[] bytes, int off)
-
parseLocalTime
public static LocalTime parseLocalTime(char c0, char c1, char c2, char c3, char c4, char c5, char c6, char c7)
-
parseLocalTime10
public static LocalTime parseLocalTime10(byte[] bytes, int off)
-
parseLocalTime10
public static LocalTime parseLocalTime10(char[] bytes, int off)
-
parseLocalTime11
public static LocalTime parseLocalTime11(byte[] bytes, int off)
-
parseLocalTime11
public static LocalTime parseLocalTime11(char[] bytes, int off)
-
parseLocalTime12
public static LocalTime parseLocalTime12(byte[] bytes, int off)
-
parseLocalTime12
public static LocalTime parseLocalTime12(char[] bytes, int off)
-
parseLocalTime18
public static LocalTime parseLocalTime18(byte[] bytes, int off)
-
parseLocalTime18
public static LocalTime parseLocalTime18(char[] bytes, int off)
-
parseLocalDateTime
public static LocalDateTime parseLocalDateTime(byte[] str, int off, int len)
-
parseLocalDate
public static LocalDate parseLocalDate(byte[] str, int off, int len)
-
parseLocalDate
public static LocalDate parseLocalDate(char[] str, int off, int len)
-
parseMillis
public static long parseMillis(byte[] bytes, int off, int len)
-
parseMillis
public static long parseMillis(byte[] bytes, int off, int len, Charset charset)
-
parseMillis
public static long parseMillis(byte[] chars, int off, int len, Charset charset, ZoneId zoneId)
-
parseMillis
public static long parseMillis(char[] bytes, int off, int len)
-
parseMillis
public static long parseMillis(char[] chars, int off, int len, ZoneId zoneId)
-
parseLocalDate8
public static LocalDate parseLocalDate8(byte[] str, int off)
yyyy-m-d yyyyMMdd d-MMM-yy
-
parseLocalDate8
public static LocalDate parseLocalDate8(char[] str, int off)
yyyy-m-d yyyyMMdd d-MMM-yy
-
parseLocalDate9
public static LocalDate parseLocalDate9(byte[] str, int off)
yyyy-MM-d yyyy-M-dd dd-MMM-yy
-
parseLocalDate9
public static LocalDate parseLocalDate9(char[] str, int off)
yyyy-MM-d yyyy-M-dd dd-MMM-yy
-
parseLocalDate10
public static LocalDate parseLocalDate10(byte[] str, int off)
yyyy-MM-dd yyyy/MM/dd MM/dd/yyyy dd.MM.yyyy yyyy年M月dd日 yyyy年MM月d日 yyyy MMM d
-
parseLocalDate10
public static LocalDate parseLocalDate10(char[] str, int off)
yyyy-MM-dd yyyy/MM/dd MM/dd/yyyy dd.MM.yyyy yyyy年M月dd日 yyyy年MM月d日 yyyy MMM d
-
parseLocalDate11
public static LocalDate parseLocalDate11(char[] str, int off)
yyyy年MM月dd日 yyyy년MM월dd일
-
parseLocalDate11
public static LocalDate parseLocalDate11(byte[] str, int off)
-
parseLocalDateTime12
public static LocalDateTime parseLocalDateTime12(char[] str, int off)
-
parseLocalDateTime12
public static LocalDateTime parseLocalDateTime12(byte[] str, int off)
parseLocalDateTime use format 'yyyyMMddHHmm'
-
parseLocalDateTime14
public static LocalDateTime parseLocalDateTime14(char[] str, int off)
yyyyMMddHHmmss
-
parseLocalDateTime14
public static LocalDateTime parseLocalDateTime14(byte[] str, int off)
yyyyMMddHHmmss
-
parseLocalDateTime16
public static LocalDateTime parseLocalDateTime16(char[] str, int off)
yyyy-MM-ddTHH:mm yyyy-MM-dd HH:mm yyyyMMddTHHmmssZ yyyy-MM-ddTH:m:s yyyy-MM-dd H:m:s
-
parseLocalDateTime16
public static LocalDateTime parseLocalDateTime16(byte[] str, int off)
yyyy-MM-ddTHH:mm yyyy-MM-dd HH:mm yyyyMMddTHHmmssZ yyyy-MM-ddTH:m:s yyyy-MM-dd H:m:s
-
parseLocalDateTime17
public static LocalDateTime parseLocalDateTime17(char[] str, int off)
yyyy-MM-ddTHH:mmZ yyyy-MM-dd HH:mmZ yyyy-M-dTHH:mm:ss yyyy-M-d HH:mm:ss
-
parseLocalDateTime17
public static LocalDateTime parseLocalDateTime17(byte[] str, int off)
yyyy-MM-ddTHH:mmZ yyyy-MM-dd HH:mmZ yyyy-M-dTHH:mm:ss yyyy-M-d HH:mm:ss
-
parseLocalDateTime18
public static LocalDateTime parseLocalDateTime18(char[] str, int off)
yyyy-M-ddTHH:mm:ss yyyy-M-dd HH:mm:ss yyyy-MM-dTHH:mm:ss yyyy-MM-d HH:mm:ss yyyy-MM-ddTH:mm:ss yyyy-MM-dd H:mm:ss yyyy-MM-ddTHH:m:ss yyyy-MM-dd HH:m:ss yyyy-MM-ddTHH:mm:s yyyy-MM-dd HH:mm:s
-
parseLocalDateTime18
public static LocalDateTime parseLocalDateTime18(byte[] str, int off)
yyyy-M-ddTHH:mm:ss yyyy-M-dd HH:mm:ss yyyy-MM-dTHH:mm:ss yyyy-MM-d HH:mm:ss yyyy-MM-ddTH:mm:ss yyyy-MM-dd H:mm:ss yyyy-MM-ddTHH:m:ss yyyy-MM-dd HH:m:ss yyyy-MM-ddTHH:mm:s yyyy-MM-dd HH:mm:s
-
parseLocalDateTime19
public static LocalDateTime parseLocalDateTime19(char[] str, int off)
yyyy-MM-ddTHH:mm:ss yyyy-MM-dd HH:mm:ss yyyy/MM/ddTHH:mm:ss yyyy/MM/dd HH:mm:ss
-
parseLocalDateTime19
public static LocalDateTime parseLocalDateTime19(String str, int off)
-
parseLocalDateTime19
public static LocalDateTime parseLocalDateTime19(byte[] str, int off)
yyyy-MM-ddTHH:mm:ss yyyy-MM-dd HH:mm:ss yyyy/MM/ddTHH:mm:ss yyyy/MM/dd HH:mm:ss
-
parseLocalDateTime20
public static LocalDateTime parseLocalDateTime20(char[] str, int off)
-
parseLocalDateTime20
public static LocalDateTime parseLocalDateTime20(byte[] str, int off)
-
parseLocalDateTime26
public static LocalDateTime parseLocalDateTime26(byte[] str, int off)
-
parseLocalDateTime26
public static LocalDateTime parseLocalDateTime26(char[] str, int off)
-
parseLocalDateTime27
public static LocalDateTime parseLocalDateTime27(byte[] str, int off)
-
parseLocalDateTime27
public static LocalDateTime parseLocalDateTime27(char[] str, int off)
-
parseLocalDateTime28
public static LocalDateTime parseLocalDateTime28(char[] str, int off)
-
parseLocalDateTime28
public static LocalDateTime parseLocalDateTime28(byte[] str, int off)
-
parseLocalDateTime29
public static LocalDateTime parseLocalDateTime29(byte[] str, int off)
-
parseLocalDateTime29
public static LocalDateTime parseLocalDateTime29(char[] str, int off)
-
parseLocalDateTimeX
public static LocalDateTime parseLocalDateTimeX(char[] str, int offset, int len)
-
parseLocalDateTimeX
public static LocalDateTime parseLocalDateTimeX(byte[] str, int offset, int len)
-
parseZonedDateTime
public static ZonedDateTime parseZonedDateTime(String str)
-
parseZonedDateTime
public static ZonedDateTime parseZonedDateTime(String str, ZoneId defaultZoneId)
-
parseZonedDateTime
public static ZonedDateTime parseZonedDateTime(byte[] str, int off, int len)
-
parseZonedDateTime
public static ZonedDateTime parseZonedDateTime(char[] str, int off, int len)
-
parseZonedDateTime
public static ZonedDateTime parseZonedDateTime(byte[] str, int off, int len, ZoneId defaultZoneId)
-
parseZonedDateTime
public static ZonedDateTime parseZonedDateTime(char[] str, int off, int len, ZoneId defaultZoneId)
-
parseMillis19
public static long parseMillis19(byte[] bytes, int off, ZoneId zoneId)
-
parseMillis19
public static long parseMillis19(char[] bytes, int off, ZoneId zoneId)
-
localDateTime
public static LocalDateTime localDateTime(char y0, char y1, char y2, char y3, char m0, char m1, char d0, char d1, char h0, char h1, char i0, char i1, char s0, char s1)
-
localDateTime
public static LocalDateTime localDateTime(char y0, char y1, char y2, char y3, char m0, char m1, char d0, char d1, char h0, char h1, char i0, char i1, char s0, char s1, char S0, char S1, char S2, char S3, char S4, char S5, char S6, char S7, char S8)
-
millis
public static long millis(LocalDateTime ldt)
-
millis
public static long millis(LocalDateTime ldt, ZoneId zoneId)
-
millis
public static long millis(ZoneId zoneId, int year, int month, int dom, int hour, int minute, int second, int nanoOfSecond)
-
utcSeconds
public static long utcSeconds(int year, int month, int dom, int hour, int minute, int second)
-
formatYMD10
public static String formatYMD10(int year, int month, int dayOfMonth)
-
formatYMDHMS19
public static String formatYMDHMS19(ZonedDateTime zdt)
-
format
public static String format(ZonedDateTime zdt, String format)
-
formatYMDHMS19
public static String formatYMDHMS19(LocalDateTime ldt)
-
format
public static String format(LocalDateTime ldt, String format)
-
format
public static String format(int year, int month, int dayOfMonth)
-
format
public static String format(int year, int month, int dayOfMonth, DateUtils.DateTimeFormatPattern pattern)
-
format
public static String format(long timeMillis)
-
format
public static String format(long timeMillis, DateUtils.DateTimeFormatPattern pattern)
-
format
public static String format(int year, int month, int dayOfMonth, int hour, int minute, int second)
-
month
public static int month(char c0, char c1, char c2)
-
hourAfterNoon
public static int hourAfterNoon(char h0, char h1)
-
getShanghaiZoneOffsetTotalSeconds
public static int getShanghaiZoneOffsetTotalSeconds(long seconds)
-
isLocalDate
public static boolean isLocalDate(String str)
-
isDate
public static boolean isDate(String str)
-
isLocalTime
public static boolean isLocalTime(String str)
-
readNanos
public static int readNanos(char[] chars, int len, int offset)
-
readNanos
public static int readNanos(byte[] bytes, int len, int offset)
-
-