在我的应用程序,我想转换给定的CDT格式化为CDT 24小时字符串格式化的12小时字符串,如何转换给定的24小时格式字符串中的12小时格式字符串??
In my application i want to convert the given CDT formatted 24 hr string in to CDT formatted 12 hr string, How to convert a given 24 hr format string in to 12 hr format string??
您可以尝试使用的SimpleDateFormat
对象转换的时间格式。
you can try using a SimpleDateFormat
object to convert the time formats.
final String time = "23:15";
try {
final SimpleDateFormat sdf = new SimpleDateFormat("H:mm");
final Date dateObj = sdf.parse(time);
System.out.println(dateObj);
System.out.println(new SimpleDateFormat("K:mm").format(dateObj));
} catch (final ParseException e) {
e.printStackTrace();
}
这里是SimpleDateFromat的Javadoc 链接。
上一篇:Angular ui-router: 1 url 触发父子状态父子、状态、ui、Angular
下一篇:在 resolve() 引发错误后重定向到模板时出现 Angular UI Router 问题重定向、模板、错误、问题