[英]Convert java.util.date format into another different java.util.date format
How Can I convert this java.util.Date format: 如何转换此java.util.Date格式:
2015-01-16 00:00:00.0
to this java.util.Date format: 更改为以下java.util.Date格式:
2015-01-16 00:00:00 GMT+00:00
You're going to need to use java.text.SimpleDateFormat
. 您将需要使用
java.text.SimpleDateFormat
。
Something as follows: 如下所示:
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
System.out.println(sdf.format(new Date()));
would print something like this: 2001-07-04 12:08:56 PDT
. 会打印如下内容:
2001-07-04 12:08:56 PDT
。
I hope that helps. 希望对您有所帮助。
Have you tried using the SimpleDateFormat? 您是否尝试过使用SimpleDateFormat?
http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.