`
phantom
  • 浏览: 162680 次
社区版块
存档分类
最新评论

我自己的数据对象处理类 UtilTime

阅读更多

package com.jh.core.db.jdbc;
/**
 * 
 * @author wanglch
 *
 */
public class TimeUtil {
 static DateFormat pathDF = new java.text.SimpleDateFormat("yyyy/MM/dd");
 static DateFormat sysDF = new java.text.SimpleDateFormat("yyyy-MM-dd");
   
 static public String getSysFormatDate() {
        return sysDF.format(new Date());
    }
 static public String getSysFormatDate(Date date) {
  if(date!=null)
         return sysDF.format(date);
        return sysDF.format(new Date());
    }
 static public String getPathFormatDate(Date date) {
     if(date!=null)
        return pathDF.format(date);
     return pathDF.format(new Date());
    }
 static public String getPathFormatDate() {
     
         return pathDF.format(new Date());
    }
    public String getSysFormatDate(String format) {
        return null;
        //Commented automatically
        //return;
    }

    public static String getDateToString(Date date) {
        DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
        return df.format(date);
    }
    public static String getDateToLString(Date date) {
        DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//2006-07-27 19:21:15
        return df.format(date);
    }
    public static String getDateToLString(long date) {
     return getDateToLString(new Date(date));
    }

    public static String getDateToString(Date date, String format) {
        DateFormat df = new java.text.SimpleDateFormat(format);
        return df.format(date);
    }
    public static String getDateToShortString(Date date) {
        DateFormat df = new java.text.SimpleDateFormat("dd/MM");
        return df.format(date);
    }
    public static java.util.Date getStrToDate(String format, String date) throws ParseException {
     if(format==null) {
     DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.parse(date);
     }
     DateFormat df = new java.text.SimpleDateFormat(format);
        return df.parse(date);

    }
    public static java.util.Date getStrToDate( String date) throws ParseException {
        return getStrToDate("yyyy-MM-dd HH:mm:ss",date);

    }

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics