ogre.dms.util
Class DateUtil

java.lang.Object
  extended by ogre.dms.util.DateUtil

public class DateUtil
extends Object


Constructor Summary
DateUtil()
           
 
Method Summary
static Date add(Calendar startDate, int field, int amount)
           
static Date add(int field, int amount)
           
static Date add(int year, int month, int date, int field, int amount)
           
static Date add(int year, int month, int date, int hour, int minute, int second, int field, int amount)
           
static Calendar createCalendar(String date)
           
static int dayCounts(Date date1, Date date2)
          Day counts between two given dates.
static String formatDateTime(Date aDate, String aFormat)
          將 Date 物件與以格式化後傳回日期時間字串,格式化字串可用的樣式請參考 SimpleDateFormat,此外,本方法增加民國年的樣式: eee。
static String getDateInFormat(Long date)
          transform the date in Long to String visible format
static long getEndOfDate(String date)
           
static long getStartOfDate(String date)
           
static String[] getTimeInteval(String timeString, String mode)
           
static void main(String[] args)
           
static Date parseDateStringToDate(String dateStr, String format)
          Parse the dateStr to Date object.
static String parseTimeFormatToString(long param)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateUtil

public DateUtil()
Method Detail

add

public static Date add(int field,
                       int amount)
Parameters:
field - Refers to java.util.Calendar
amount - the number to add to.
Returns:
the Date object representing the resulting date.

add

public static Date add(Calendar startDate,
                       int field,
                       int amount)
Parameters:
startDate - the start date object
field - Refers to java.util.Calendar
amount - the number to add to the start date.
Returns:
the Date object representing the resulting date.

add

public static Date add(int year,
                       int month,
                       int date,
                       int hour,
                       int minute,
                       int second,
                       int field,
                       int amount)
Parameters:
year -
month -
date -
hour - int
minute - int
second - int
field - Refers to java.util.Calendar
amount - the number to add to the start date.
Returns:
the Date object representing the resulting date.

add

public static Date add(int year,
                       int month,
                       int date,
                       int field,
                       int amount)
Parameters:
year -
month -
date -
field - Refers to java.util.Calendar
amount - the number to add to the start date.
Returns:
the Date object representing the resulting date.

dayCounts

public static int dayCounts(Date date1,
                            Date date2)
Day counts between two given dates.

Parameters:
date1 - Date
date2 - Date
Returns:
int positive counts

formatDateTime

public static String formatDateTime(Date aDate,
                                    String aFormat)
將 Date 物件與以格式化後傳回日期時間字串,格式化字串可用的樣式請參考 SimpleDateFormat,此外,本方法增加民國年的樣式: eee。 注意:民國前的年份會傳回負數,例如:-001/3/26。 使用範例: s = DateUtil.formatDateTime(new Date(), "eee/mm/dd");

Parameters:
aDate - 日期物件
aFormat - 格式化字串
Returns:
格式化後的日期時間字串

getDateInFormat

public static String getDateInFormat(Long date)
transform the date in Long to String visible format


parseDateStringToDate

public static Date parseDateStringToDate(String dateStr,
                                         String format)
Parse the dateStr to Date object.

Parameters:
dateStr -
format -
Returns:
if failed, null will be returned.

getStartOfDate

public static long getStartOfDate(String date)

getEndOfDate

public static long getEndOfDate(String date)

createCalendar

public static Calendar createCalendar(String date)

main

public static void main(String[] args)

parseTimeFormatToString

public static String parseTimeFormatToString(long param)
Parameters:
param: - date time in long format

getTimeInteval

public static String[] getTimeInteval(String timeString,
                                      String mode)


Copyright(c) 2005-2012 by Flowring Technology Corp., 12 F., No 120, Sec 2, Gongdao 5th Rd., Hsin-Chu City 300, Taiwan(R.O.C.) All rights reserved.