嗨,谁能告诉我如何将给定的时间戳格式更改为其他时间戳格式
喜欢
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar d1 = Calendar.getInstance();
d1.setTime(formatter.parse("2012-03-08 17:32:56"));
至
"dd-MMM-yyyy HH:mm:ss"
格式
最佳答案
用新的日期格式格式化日期dd-MMM-yyyy HH:mm:ss
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date oldFormatedDate = formatter.parse("2012-03-08 17:32:56");
System.out.println(new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss").
format(oldFormatedDate));