Java代码生成时间戳


Date date = new Date();
//样式:yyyy年MM月dd日HH时mm分ss秒SSS毫秒
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒SSS毫秒");
String timeStampStr = simpleDateFormat.format(date);

样式参考如下:
public static String datePattern = "yyyy-MM-dd";
public static String timePattern = "yyyy-MM-dd HH:mm";
public static String dateMoth = "yyyy-MM";
public static String timePattern2 = "yyyy-MM-dd HH:mm:ss";
public static String timeForAlarm = "yyyy.MM.dd HH:mm:ss";
public static String timePattern3 = "yyyy年MM月dd日HH时";

你可能感兴趣的:(Java学习)