String expiryDate = "2016-03-14";
private String formatDateTime(String expiryDate, String expiryTime) {
SimpleDateFormat input = new SimpleDateFormat("yyyy-mm-dd");
SimpleDateFormat output = new SimpleDateFormat("MMM, dd, yyyy");
try {
String formattedDate = output.format(input.parse(expiryDate ));// parse input
return formattedDate + ", " + expiryTime;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
然而,当它返回时,它给出的是 2016 年 1 月 14 日。
期望的输出是 2016 年 3 月 14 日
mm
应该是资本MM
。因为
mm代表分钟MM代表月份
所以你的格式应该是这样的
SimpleDateFormat input = new SimpleDateFormat("yyyy-MM-dd");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)