日期:2014-05-16  浏览次数:20947 次

org.apache.commons.lang.time.DateUtils(常用的一些函数)
static java.util.Date addDays(java.util.Date date,int amount) 
          //Adds a number of days to a date returning a new object.
          //一个日期对象+n天
static java.util.Date addHours(java.util.Date date,int amount)
        //Adds a number of hours to a date returning a new object.
          //一个日期对象+n小时
static java.util.Date addMilliseconds(java.util.Date date,int amount) 
          //Adds a number of milliseconds to a date returning a new object.
          //一个日期对象+n毫秒
static java.util.Date addMinutes(java.util.Date date,int amount) 
          //Adds a number of minutes to a date returning a new object.
          //一个日期对象+n分
static java.util.Date addMonths(java.util.Date date,int amount) 
          //Adds a number of months to a date returning a new object.
          //一个日期对象+n月
static java.util.Date addSeconds(java.util.Date date,int amount)
        //Adds a number of seconds to a date returning a new object.
        //一个日期对象+n秒
static java.util.Date addWeeks(java.util.Date date,int amount) 
          //Adds a number of weeks to a date returning a new object.
          //一个日期对象+N个星期
static java.util.Date addYears(java.util.Date date,int amount) 
          //Adds a number of years to a date returning a new object.
          //一个日期对象+N年
static boolean isSameDay(java.util.Date date1,java.util.Date date2) 
          //Checks if two date objects are on the same day ignoring time.
          //两个日期对象是否相等(只比较年-月-日)
static boolean isSameInstant(java.util.Date date1,java.util.Date date2) 
          //Checks if two date objects represent the same instant in time.
          //比较两个日期是否完全相等(精确到毫秒)
static java.util.Date parseDate(java.lang.String str,java.lang.String[] parsePatterns)
          //Parses a string representing a date by trying a variety of different parsers.
         //例 :
           String[] format={"yyyy-MM-dd"};
           System.out.println(DateUtils.parseDate("2009-10-20",format));