记住
Date对象没有固有的格式,您需要两个
DateFormat对象来产生想要的结果-一个要解析,另一个要格式化:
String input = "2014-04-25 17:03:13";DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");DateFormat outputFormat = new SimpleDateFormat("'Date : 'dd-MM-yyyyn'Time : 'KK:mm a");System.out.println(outputFormat.format(inputFormat.parse(input)));输出:
Date : 25-04-2014Time : 05:03 PM
请注意,在格式中使用带引号的序列(例如)
"'Date : '",它被视为格式模式中的文字。



