日期转换类

来源:互联网 发布:es大数据实时分析 编辑:程序博客网 时间:2024/06/15 17:33
package class1;
import java.text.SimpleDateFormat;
import java.util.Date;
class DateTime {
private SimpleDateFormat sdf = null ;
public String getDate() {
this.sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss.SSS") ;
return this.sdf.format(new Date()) ;
}
public String getDateComplete() {
this.sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒SSS毫秒");
return this.sdf.format(new Date());
}
public String getTimeStamp() {
this.sdf = new SimpleDateFormat("yyyMMddHHmmssSSS") ;
return this.sdf.format(new Date()) ;
}
}
public class DateDemo07 {
public static void main(String[] args) {
DateTime dt  = new DateTime() ;
System.out.println("系统日期:" + dt.getDate());
System.out.println("中文日期:" + dt.getDateComplete());
System.out.println("时间:" + dt.getTimeStamp());
}
}
原创粉丝点击