public class DateTimeUtil extends BaseUtil
DateTime is the standard implementation of an unmodifiable datetime class. The pattern syntax is mostly compatible with java.text.SimpleDateFormat Symbol Meaning Presentation Examples ------ ------- ------------ ------- G era text AD C century of era number 20 Y year of era year 1996 x weekyear year 1996 w week of weekyear number 27 e day of week number 2 E day of week text Tuesday; Tue y year year 1996 D day of year number 189 M month of year month July; Jul; 07 d day of month number 10 a halfday of day text PM K hour of halfday (0~11) number 0 h clockhour of halfday (1~12) number 12 H hour of day (0~23) number 0 k clockhour of day (1~24) number 24 m minute of hour number 30 s second of minute number 55 S fraction of second number 978 z time zone text Pacific Standard Time; PST Z time zone offset/id zone -0800; -08:00; America/Los_Angeles ' escape for text delimiter '' single quote literal '
限定符和类型 | 字段和说明 |
---|---|
protected static Locale |
DEFAULT_LOCALE
地区: 中国
|
protected static String |
DEFAULT_PATTERN
日期格式: 中国
|
protected static org.joda.time.DateTimeZone |
DEFAULT_TIMEZONE
时区:正八区 / (UTC+08:00)北京,重庆,香港特别行政区,乌鲁木齐
|
构造器和说明 |
---|
DateTimeUtil() |
限定符和类型 | 方法和说明 |
---|---|
static Date |
getCurrentDate() |
static org.joda.time.DateTime |
getCurrentDateTime() |
static String |
getCurrentTime()
返回当前系统时间
|
static org.joda.time.DateTime |
getDateTime(Date date)
转换 date 为 DateTime 对象
|
static org.joda.time.format.DateTimeFormatter |
getDateTimeFormatter(String pattern) |
static org.joda.time.DateTime |
getDateTimeFromYearWeek(String yearWeek)
返回指定 年周(比如200953) 的第一天的日期
referer:
http://joda-time.sourceforge.net/api-release/org/joda/time/format
/DateTimeFormat.html
|
static String |
getFormatedDate(Date date,
String pattern)
返回指定日期的字符串
|
static String |
getFormatedDate(int days,
String pattern)
返回指定日期的字符串
|
static String |
getFormatedDateTime(org.joda.time.DateTime dt,
String pattern)
返回格式化的字符串
|
static String |
getYearMonth(Date date)
获取指定日期的年月
|
static String |
getYearWeek(Date date)
获取指定日期的年周
|
static org.joda.time.DateTime |
parseDateTime(String date,
String pattern)
转换字符串为 DateTime 对象
|
convertMapValue
protected static final Locale DEFAULT_LOCALE
protected static final org.joda.time.DateTimeZone DEFAULT_TIMEZONE
public static Date getCurrentDate()
public static org.joda.time.DateTime getCurrentDateTime()
public static String getCurrentTime()
public static org.joda.time.DateTime getDateTime(Date date)
date
- date objectpublic static org.joda.time.format.DateTimeFormatter getDateTimeFormatter(String pattern)
public static org.joda.time.DateTime getDateTimeFromYearWeek(String yearWeek)
referer: http://joda-time.sourceforge.net/api-release/org/joda/time/format /DateTimeFormat.html
yearWeek
- yearWeekpublic static String getFormatedDate(Date date, String pattern)
date
- 指定的日期对象pattern
- 格式字符串,可选,默认 yyyy-MM-ddpublic static String getFormatedDate(int days, String pattern)
days
- 日期相差的天数pattern
- 格式字符串,可选,默认 yyyy-MM-ddpublic static String getFormatedDateTime(org.joda.time.DateTime dt, String pattern)
dt
- DateTimepattern
- date patternpublic static String getYearMonth(Date date)
date
- 日期对象public static String getYearWeek(Date date)
date
- 日期对象Copyright © 2015 jiucai.org. All rights reserved.