java关于时间处理的函数

来源:互联网 发布:淘宝水印美图秀秀教程 编辑:程序博客网 时间:2024/05/16 14:15

import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.Test;

public class Dateutil {

private SimpleDateFormat sdf=null;private String getDate(){    this.sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:SS.sss");    return this.sdf.format(new Date());}//生成时间格式2017-07-23 09:06:988.049private String getDateCoplete(){    this.sdf=new SimpleDateFormat("yyyy年MM月dd日 HH时mm分SS秒sss毫秒");    return this.sdf.format(new Date());}//生成时间格式2017年07月23日 09时06分988秒049毫秒private String getDateCopletes(){    this.sdf=new SimpleDateFormat("yyyyMMddHHmSSsss");    return this.sdf.format(new Date());}//生成时间格式20170723096988049}