public class TimeKit extends Object
| 构造器和说明 |
|---|
TimeKit() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
format(Date date) |
static String |
format(Date date,
String pattern)
按指定 pattern 将 Date 转换成 String
例如:format(new Date(), "yyyy-MM-dd HH:mm:ss")
|
static String |
format(LocalDate localDate,
String pattern)
按指定 pattern 将 LocalDate 转换成 String
|
static String |
format(LocalDateTime localDateTime) |
static String |
format(LocalDateTime localDateTime,
String pattern)
按指定 pattern 将 LocalDateTime 转换成 String
例如:format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss")
|
static String |
format(LocalTime localTime,
String pattern)
按指定 pattern 将 LocalTime 转换成 String
|
static DateTimeFormatter |
getDateTimeFormatter(String pattern) |
static SimpleDateFormat |
getSimpleDateFormat(String pattern) |
static boolean |
isAfter(ChronoLocalDateTime<?> self,
ChronoLocalDateTime<?> other)
判断 A 的时间是否在 B 的时间 "之后"
|
static boolean |
isBefore(ChronoLocalDateTime<?> self,
ChronoLocalDateTime<?> other)
判断 A 的时间是否在 B 的时间 "之前"
|
static boolean |
isEqual(ChronoLocalDateTime<?> self,
ChronoLocalDateTime<?> other)
判断 A 的时间是否与 B 的时间 "相同"
|
static String |
now(String pattern)
按指定 pattern 将当前时间转换成 String
例如:now("yyyy-MM-dd HH:mm:ss")
|
static Date |
parse(String dateString,
String pattern)
按指定 pattern 将 String 转换成 Date
|
static LocalDate |
parseLocalDate(String localDateString,
String pattern)
按指定 pattern 将 String 转换成 LocalDate
|
static LocalDateTime |
parseLocalDateTime(String localDateTimeString,
String pattern)
按指定 pattern 将 String 转换成 LocalDateTime
|
static LocalTime |
parseLocalTime(String localTimeString,
String pattern)
按指定 pattern 将 String 转换成 LocalTime
|
static Date |
toDate(LocalDate localDate)
java.time.LocalDate --> java.util.Date
|
static Date |
toDate(LocalDate localDate,
LocalTime localTime)
java.time.LocalTime --> java.util.Date
|
static Date |
toDate(LocalDateTime localDateTime)
java.time.LocalDateTime --> java.util.Date
|
static Date |
toDate(LocalTime localTime)
java.time.LocalTime --> java.util.Date
|
static LocalDate |
toLocalDate(Date date)
java.util.Date --> java.time.LocalDate
|
static LocalDateTime |
toLocalDateTime(Date date)
java.util.Date --> java.time.LocalDateTime
|
static LocalTime |
toLocalTime(Date date)
java.util.Date --> java.time.LocalTime
|
public static DateTimeFormatter getDateTimeFormatter(String pattern)
public static SimpleDateFormat getSimpleDateFormat(String pattern)
public static String now(String pattern)
public static String format(LocalDateTime localDateTime, String pattern)
public static String format(LocalDateTime localDateTime)
public static String format(LocalDate localDate, String pattern)
public static String format(LocalTime localTime, String pattern)
public static String format(Date date, String pattern)
public static LocalDateTime parseLocalDateTime(String localDateTimeString, String pattern)
public static LocalDate parseLocalDate(String localDateString, String pattern)
public static LocalTime parseLocalTime(String localTimeString, String pattern)
public static boolean isAfter(ChronoLocalDateTime<?> self, ChronoLocalDateTime<?> other)
public static boolean isBefore(ChronoLocalDateTime<?> self, ChronoLocalDateTime<?> other)
public static boolean isEqual(ChronoLocalDateTime<?> self, ChronoLocalDateTime<?> other)
public static LocalDateTime toLocalDateTime(Date date)
public static Date toDate(LocalDateTime localDateTime)
Copyright © 2024. All rights reserved.