Java 如何格式化中国标准时间
2017-04-06 00:00
2361 查看
摘要: Java 如何格式化中国标准时间
public static void main(String[] args) {
try {
String strDate = "Fri Mar 31 2017 00:00:00 GMT+0800 (中国标准时间)";
strDate = strDate.replace("GMT", "").replaceAll("\\(.*\\)", "");
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss", Locale.ENGLISH);
Date date = format.parse(strDate);
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(date));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
String strDate = "Fri Mar 31 2017 00:00:00 GMT+0800 (中国标准时间)";
strDate = strDate.replace("GMT", "").replaceAll("\\(.*\\)", "");
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss", Locale.ENGLISH);
Date date = format.parse(strDate);
System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(date));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
相关文章推荐
- Java 如何格式化中国标准时间
- Java 9的日期时间格式化趋近Unicode区域设置标准
- JAVA将字符串Sat Nov 25 2017 00:00:00 GMT+0800 (中国标准时间)转成标准时间
- js 格式化 extjs 的时间对象 Thu May 12 2016 08:00:00 GMT+0800 (中国标准时间)
- JS工作随笔 05 JS格式化Thu May 12 2016 08:00:00 GMT+0800 (中国标准时间)
- Java - 日期和时间:- 如何取得年月日、时分秒?- 如何取得从1970年1月1日0时0分0秒到现在的毫秒数?- 如何取得某月的最后一天?- 如何格式化日期?
- java.util.Calendar不能正确处理中国标准时间的"1900-01-01 08:00:00 000"
- java中如何获得当前时间以及日期格式化的 4000 详解
- java获取给定时区时间,中国标准时.格林威治时间
- JS格式化Thu May 12 2017 08:00:00 GMT+0800 (中国标准时间)
- JAVA如何获得日期以及时间
- [Boost]如何将UNIX风格时间转换为标准格式
- [Boost]如何将UNIX风格时间转换为标准格式
- 如何用Java实现网络中国象棋室(二)
- Java处理时间格式化
- java中获取当前系统时间,日期并格式化输出
- 如何加快 Java Applet程序的下载时间
- [Boost]如何将UNIX风格时间转换为标准格式
- 如何使用JAVA 去很好的控制输出的时间
- java 时间操作 格式化 时区 系统时间