我正在尝试格式化 Date 对象并将格式化的对象转换回 Date 类型对象
这是我的代码
SimpleDateFormat inputDf = new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss zzz");
System.out.println("before format "+invoiceDate);
invoiceDate=inputDf.parse(inputDf.format(invoiceDate));
System.out.println("after format "+inputDf.format(invoiceDate));
System.out.println("after parse "+invoiceDate);
从上面的代码输出是
before format : Mon Jan 14 10:55:40 IST 2013
after format : Mon Jan 14 2013 10:55:40 IST
after parse : Mon Jan 14 10:55:40 IST 2013
您可以在我解析日期对象后将其转换回原始格式(在格式之前显示的格式),但我希望 Date 对象像它出现在第二个打印行(格式之后)一样是 .format 方法返回字符串而不是 Date 对象, 我怎样才能解决这个问题 ?
谢谢