public class DateUtils extends Object
时间处理工具类
author : Crab2Died date : 2017/5/23 10:35| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DATE_FORMAT_DAY |
static String |
DATE_FORMAT_DAY_2 |
static String |
DATE_FORMAT_DAY_SIMPLE |
static String |
DATE_FORMAT_MSEC |
static String |
DATE_FORMAT_MSEC_T |
static String |
DATE_FORMAT_MSEC_T_Z |
static String |
DATE_FORMAT_SEC |
static String |
TIME_FORMAT_SEC |
| 构造器和说明 |
|---|
DateUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
date2Str(Date date)
将
Date类型转换为默认为[yyyy-MM-dd HH:mm:ss]类型的字符串
author : Crab2Died
date : 2017年06月02日 15:30:01 |
static String |
date2Str(Date date,
String format)
将
Date类型转换为指定格式的字符串
author : Crab2Died
date : 2017年06月02日 15:32:04 |
static Date |
str2Date(String strDate)
字符串时间转为
Date类型,
未找到匹配类型则抛出TimeMatchFormatException异常
支持匹配类型列表:
yyyy-MM-dd
yyyy/MM/dd
HH:mm:ss
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd'T'HH:mm:ss.SSS
yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
author : Crab2Died
date : 2017年06月02日 15:21:54 |
static Date |
str2Date(String strDate,
String format)
根据给出的格式化类型将时间字符串转为
Date类型
author : Crab2Died
date : 2017年06月02日 15:27:22 |
static Date |
str2DateUnmatch2Null(String strDate)
字符串时间转为
Date类型,未找到匹配类型则返NULL
支持匹配类型列表:
yyyy-MM-dd
yyyy/MM/dd
HH:mm:ss
yyyy-MM-dd HH:mm:ss
yyyy-MM-dTHH:mm:ss.SSS
author : Crab2Died
date : 2017年06月02日 15:21:54 |
public static String date2Str(Date date, String format)
将Date类型转换为指定格式的字符串
date - Date类型的时间format - 指定格式化类型public static String date2Str(Date date)
将Date类型转换为默认为[yyyy-MM-dd HH:mm:ss]类型的字符串
date - Date类型的时间public static Date str2Date(String strDate, String format)
根据给出的格式化类型将时间字符串转为Date类型
strDate - 时间字符串format - 格式化类型Date类型public static Date str2Date(String strDate) throws ParseException
字符串时间转为Date类型,
未找到匹配类型则抛出TimeMatchFormatException异常
支持匹配类型列表:
yyyy-MM-dd
yyyy/MM/dd
HH:mm:ss
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd'T'HH:mm:ss.SSS
yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
author : Crab2Died date : 2017年06月02日 15:21:54
strDate - 时间字符串Date时间ParseException - 异常Copyright © 2020. All rights reserved.