我想在日期時間中使用SimpleFormatMethod
,例如 - 09/20/2016 10:10:10 PM
。正如我在谷歌發現,它可以像 -SimpleDateFormat方法中AM/PM的值
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss.SSS ?");
,但什麼都要到位?
它代表AM/PM
我想在日期時間中使用SimpleFormatMethod
,例如 - 09/20/2016 10:10:10 PM
。正如我在谷歌發現,它可以像 -SimpleDateFormat方法中AM/PM的值
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss.SSS ?");
,但什麼都要到位?
它代表AM/PM
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss.SSS aaa");
按SimpleDateFormat docs :「Am/pm marker」是字母a
。
所以你的情況,你想:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss.SSS a");
SimpleDateFormat 「AM/PM標記」 是信a
。 您可以按照文件更多的幫助
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy kk:mm:ss.SSS aaa");
[在Java字符串更改日期格式(可能的重複http://stackoverflow.com/questions/4772425/change-date-format-in-a-java -串) – Tom