SimpleDateFormat将月/日/年 时分秒转换为年-月-日 时:分:秒

String expirTime = ”12 / 27 / 2018 12: 00: 00 AM”;
SimpleDateFormat in = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
SimpleDateFormat out = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
try {
idpData.setExpirationTime(out.format( in .parse(expirTime)));
System.out.println(idpData.getExpirationTime());
} catch (Exception e1) {
e1.printStackTrace();
}

猜你喜欢

转载自www.cnblogs.com/mengmenging/p/10300308.html
今日推荐