Date 与 SimpleDateFormat

SimpleDateFormat 将时间格式化

主要的格式有 yyyy-MM-dd hh:mm:ss //注意 大写的MM为月 小写的mm 为分  大写的H 与小写的h表示的时间不同(12、24);

SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = simple.parse(sDateTime); //将格式化的字符串转为Date

SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df.format(lastData);// 将Date转为格式化的字符串

原文地址:https://www.cnblogs.com/lipeil/p/2567242.html