public class DateUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
day(Date date)
获取天
|
static String |
dm(String ymd)
日期转换为DDMMM格式
|
static String |
format(Date date,
String pattern)
将日期转换成指定格式的字符串
|
static int |
get(int type,
Date date)
某日期的某类型的数值
|
static String |
hms(Date date)
将日期转换成HH:mm:ss格式的字符串
|
static String |
month(Date date)
获取月份
|
static String |
monthCH(Date date)
获取某日期的月份中文表示
|
static Date |
next(Date date,
int days)
获得后几天的日期
|
static Date |
next(int type,
Date date,
int length)
指定类型往后推
|
static Date |
nextMonth(Date date,
int months)
月份往后推的日期
|
static Date |
nextYear(Date date,
int years)
年份往后推的日期
|
static Date |
now()
获取当前时间
|
static Date |
parse(String s,
String pattern)
将指定格式字符串转换为日期
|
static Date |
previous(Date date,
int days)
获得前几天的日期
|
static Date |
previous(int type,
Date date,
int length)
指定类型往前推
|
static Date |
previousMonth(Date date,
int months)
月份往前推的日期
|
static Date |
previousYear(Date date,
int years)
年份往前推的日期
|
static String |
weekCH(Date date)
获取某日期的星期中文表示
|
static int |
year(Date date)
获取年份
|
static String |
yearCH(Date date)
获取某日期的年份中文表示
|
static String |
ymd(Date date)
将日期转换成yyyy-MM-dd格式的字符串
|
static String |
ymd(String dayMonthYear)
日期字符串转换为YYYY-MM-DD格式
|
static String |
ymd(String dayMonthYear,
String yearPrefix)
日期字符串转换为YYYY-MM-DD格式
|
static Date |
ymd2Date(String ymd)
将yyyy-MM-dd或yyyy/MM/dd格式的日期字符串转换为日期类型
|
static String |
ymdhms(Date date)
将日期转换成yyyy-MM-dd HH:mm:ss格式的字符串
|
static Date |
ymdhms2Date(String ymdhms)
将yyyy-MM-dd HH:mm:ss格式的日期字符串转换为日期类型
|
public static Date now()
public static Date ymd2Date(String ymd) throws ParseException
ymd - yyyy-MM-dd或yyyy/MM/dd格式的字符串ParseException - 日期转换异常public static Date ymdhms2Date(String ymdhms) throws ParseException
ymdhms - yyyy-MM-dd HH:mm:ss格式的字符串ParseException - 日期转换异常public static Date parse(String s, String pattern) throws ParseException
s - 字符串pattern - 格式ParseException - 转换异常public static String ymdhms(Date date)
date - 日期public static String format(Date date, String pattern)
date - 日期public static Date previous(int type, Date date, int length)
type - 类型:年、月、日等date - 参考日期length - 长度public static Date next(int type, Date date, int length)
type - 类型:年、月、日等date - 参考日期length - 长度public static Date nextMonth(Date date, int months)
date - 参考日期months - 推后几个月public static Date previousMonth(Date date, int months)
date - 参考日期months - 前推几个月public static Date nextYear(Date date, int years)
date - 参考日期years - 推后几年public static Date previousYear(Date date, int years)
date - 参考日期years - 前推几年public static int get(int type,
Date date)
type - 类型:年、月、日等date - 日期public static int year(Date date)
date - 日期public static String dm(String ymd)
ymd - YYYY-MM-DD格式的字符串public static String ymd(String dayMonthYear)
dayMonthYear - 支持的参数格式: 1MAY 01MAY 1MAY10 01MAY10 1MAY2010 01MAY2010,不区分大小写,以上转换后为2010-05-01public static String ymd(String dayMonthYear, String yearPrefix)
dayMonthYear - 支持的参数格式: 1MAY 01MAY 1MAY10 01MAY10 1MAY2010 01MAY2010yearPrefix - 年份前缀,如yearPrefix=19,1MAY09=1909-05-01Copyright © 2023. All Rights Reserved.