public class DateUtil extends Object
| 构造器和说明 |
|---|
DateUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static LocalDate |
date2LocalDate(Date date)
日期转本地日期
|
static LocalDateTime |
date2LocalDateTime(Date date)
日期转日期时间
|
static Date |
from(String time)
字符串转Date
|
static Date |
from(String time,
String format)
字符串转Date
|
static String |
getByDayOffset(int offset)
获取偏移多少天的日期
|
static String |
getByDayOffset(String format,
int offset)
获取偏移多少天的日期
|
static String |
getDayMonthAgo()
获取30天前的日期
|
static int |
getDayOfWeek()
获取星期几(int)
|
static String |
getDayWeekAgo()
获取7天前的日期
|
static int |
getMonthDays(int year,
int month)
获取某个月份的天数
|
static int |
getNowMonthDays()
获取当前月份的天数
|
static Date |
local2Date(LocalDate date)
本地日期转日期
|
static Date |
local2Date(LocalDateTime time)
本地日期时间转日期
|
static String |
now(String format)
按格式化条件获取当前时间
|
static String |
nowDate()
获取当前日期
|
static String |
nowMilli()
获取当前时间到毫秒
|
static String |
nowTime()
获取当前时间,到秒
|
static String |
parse(String format,
Date date)
解析日期未字符串
|
static String |
parse(String format,
long time)
解析long未日期字符串
|
static String |
to(Date date)
日期转日期字符串
|
static String |
to(Date date,
String format)
日期按格式化转字符串
|
static String |
to(LocalDateTime dateTime,
String format)
日期时间按格式化转字符串
|
@Nonnull public static Date from(@Nonnull String time, @Nonnull String format)
time - 时间字符串format - 格式化@Nonnull public static String now(@Nonnull String format)
format - 格式化@Nonnull public static String to(@Nonnull Date date, @Nonnull String format)
date - 日期format - 格式化@Nonnull public static String to(@Nullable LocalDateTime dateTime, @Nonnull String format)
dateTime - 日期时间format - 格式化public static int getDayOfWeek()
@Nonnull public static Date local2Date(@Nonnull LocalDateTime time)
time - 日期时间@Nonnull public static Date local2Date(@Nonnull LocalDate date)
date - 本地日期@Nonnull public static LocalDateTime date2LocalDateTime(@Nullable Date date)
date - 日期@Nonnull public static LocalDate date2LocalDate(@Nullable Date date)
date - 日期@Nonnull public static String parse(@Nonnull String format, @Nonnull Date date)
format - 格式化date - 日期@Nonnull public static String parse(@Nonnull String format, long time)
format - 格式化time - 时间@Nonnull public static String getByDayOffset(@Nonnull String format, int offset)
format - 格式化offset - 偏移天数@Nonnull public static String getByDayOffset(int offset)
offset - 偏移public static int getMonthDays(int year,
int month)
year - 年month - 月份public static int getNowMonthDays()
Copyright © 2018. All rights reserved.