goo*_*oid 3 java datetime android simpledateformat
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;
}
Run Code Online (Sandbox Code Playgroud)
但是当它返回它时,2016年1月14日.
期望的产量是2016年3月14日
mm应该是资本MM.怎么一回事,因为
mm代表分钟 MM代表月份
所以你的格式应该是这样的
SimpleDateFormat input = new SimpleDateFormat("yyyy-MM-dd");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
868 次 |
| 最近记录: |