org.jiucai.appframework.base.util
类 DateTimeUtil

java.lang.Object
  继承者 org.jiucai.appframework.common.util.BaseUtil
      继承者 org.jiucai.appframework.base.util.DateTimeUtil

public class DateTimeUtil
extends BaseUtil

DateTime 工具类 referer: http://joda-time.sourceforge.net/api-release/index.html

 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 (>=0)         number        20
 Y       year of era (>=0)            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       '
 

作者:
zhaidw

字段摘要
protected static Locale DEFAULT_LOCALE
          地区: 中国
protected static String DEFAULT_PATTERN
          日期格式: 中国
protected static org.joda.time.DateTimeZone DEFAULT_TIMEZONE
          时区:正八区 / (UTC+08:00)北京,重庆,香港特别行政区,乌鲁木齐
 
从类 org.jiucai.appframework.common.util.BaseUtil 继承的字段
log
 
构造方法摘要
DateTimeUtil()
           
 
方法摘要
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 对象
 
从类 org.jiucai.appframework.common.util.BaseUtil 继承的方法
convertMapValue
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

DEFAULT_PATTERN

protected static final String DEFAULT_PATTERN
日期格式: 中国

另请参见:
常量字段值

DEFAULT_LOCALE

protected static final Locale DEFAULT_LOCALE
地区: 中国


DEFAULT_TIMEZONE

protected static final org.joda.time.DateTimeZone DEFAULT_TIMEZONE
时区:正八区 / (UTC+08:00)北京,重庆,香港特别行政区,乌鲁木齐

构造方法详细信息

DateTimeUtil

public DateTimeUtil()
方法详细信息

getDateTimeFormatter

public static org.joda.time.format.DateTimeFormatter getDateTimeFormatter(String pattern)

parseDateTime

public static org.joda.time.DateTime parseDateTime(String date,
                                                   String pattern)
转换字符串为 DateTime 对象

参数:
date -
pattern -
返回:
DateTime

getDateTime

public static org.joda.time.DateTime getDateTime(Date date)
转换 date 为 DateTime 对象

参数:
date -
返回:
DateTime

getFormatedDateTime

public static String getFormatedDateTime(org.joda.time.DateTime dt,
                                         String pattern)
返回格式化的字符串

参数:
dt -
pattern -
返回:
String

getFormatedDate

public static String getFormatedDate(Date date,
                                     String pattern)
返回指定日期的字符串

参数:
date - 指定的日期对象
pattern - 格式字符串,可选,默认 yyyy-mm-dd
返回:
String

getFormatedDate

public static String getFormatedDate(int days,
                                     String pattern)
返回指定日期的字符串

参数:
days - 日期相差的天数
pattern - 格式字符串,可选,默认 yyyy-mm-dd
返回:
String

getYearMonth

public static String getYearMonth(Date date)
获取指定日期的年月

参数:
date - 日期对象
返回:
格式, yyyymm, 示例值 200908

getYearWeek

public static String getYearWeek(Date date)
获取指定日期的年周

参数:
date - 日期对象
返回:
格式, yyyyww, 示例值 200953

getDateTimeFromYearWeek

public static org.joda.time.DateTime getDateTimeFromYearWeek(String yearWeek)
返回指定 年周(比如200953) 的第一天的日期

referer: http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html

返回:
DateTime

getCurrentTime

public static String getCurrentTime()
返回当前系统时间

返回:
String


Copyright © 2013. All Rights Reserved.