java使用格式String型轉成Date型
阿新 • • 發佈:2018-05-31
simple ace for long new time int TE cal
public class TimeTwo {
public static void main(String[] args) throws ParseException{
String s = "2018-08-12 12:02:23";
SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd MM:mm:ss");
try{
Date h = g.parse(s);
// System.out.println(h);
}catch (ParseException e){
e.printStackTrace();
}
//格式String型轉成Date型
DateFormat format3 = DateFormat.getDateInstance(DateFormat.LONG,Locale.SIMPLIFIED_CHINESE);
try{
System.out.println("日期:"+format3.format(new Date()));
}catch (Exception e){
e.printStackTrace();
}
}
}
java使用格式String型轉成Date型