SimpleDateFormat 12 小时制和24小时制实现
2016-12-12 15:41
260 查看
SimpleDateFormat 12 小时制和24小时制实现
// SimpleDateFormat ss = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//12小时制// SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//24小时制
看测试代码:
/**
* 版权所有 (c) 2016,
*/
package helloTest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
* 类说明:
*
* <pre>
* Modify Information:
* Author Date Description
* ============ =========== ============================
* 2016-6-21 Create this file
* </pre>
*
*/
public class Test {
public static void main(String[] args) {
String valueString = "20161031161121711";
// SimpleDateFormat ss = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//12小时制
// SimpleDateFormat sdformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//24小时制
SimpleDateFormat origFormat = new SimpleDateFormat("yyyyMMddhhmmssSSS");//17位精确到ms
SimpleDateFormat destFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
System.out.println(destFormat.format(origFormat.parse(valueString)));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
相关文章推荐
- java---SimpleDateFormat---实现字符串和日期类型互相转换
- SimpleDateFormat的24小时制和12小时制
- SimpleDateFormat 24小时和12小时转换
- SimpleDateFormat 24小时制时间显示
- js实现SimpleDateFormat
- 一个简单的Java对象池实现——可用来解决SimpleDateFormat的线程安全问题
- SimpleDateFormat显示格式如2017-05-20 15:00:10,怎么显示为24小时的格式,而不是2017-05-20 3:00:10
- 计算食品保质期的前一个星期日,以便做促销的方法(SimpleDateFormat,Calendar等)实现
- SimpleDateFormat与Calendar的24小时制与12小时制
- SimpleDateFormat实现String与Date之间的转换
- SimpleDateFormat 12小时制以及24小时制的写法
- SimpleDateFormat的12小时制和24小时制
- J2EE-SimpleDateFormat的12小时制和24小时制
- Android 使用SimpleDateFormat以及Calendar转换时间为12小时制和24小时制时间格式
- java基础-高效利用SimpleDateFormat实现日期的转换
- SimpleDateFormat 24小时和12小时转换
- java中使用SimpleDateFormat实现字符串和日期的相互转换
- 使用SimpleDateFormat实现String、Date互转
- SimpleDateFormat设置24小时制
- 使用DateLocaleConverter和SimpleDateFormat实现字符串转换成日期的区别