Java的公历,以特定的格式 [英] Java Gregorian calendar to specific format

查看:169
本文介绍了Java的公历,以特定的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图公历格式化为特定的格式,以实现web服务,但我不知道如何使它优雅。
现在,我想的格式通过获取分钟的时间,并分析他们,但它看起来太可怕了。
我需要把它格式化为XSD:日期时间2001-10-26T21:32:52,2001
任何有助于AP preciated。
谢谢!

I've been trying to format a gregorian calendar to a specific format as to fulfill a webservice but I don't know how to make it elegant. Right now I'm trying to format by getting the hour of minute and parsing them but it looks horrible. I need to format it as xsd:dateTime 2001-10-26T21:32:52, 2001 Any helps appreciated. Thanks!

推荐答案

要直盼着的格式调整到你所需要的?
这将产生2013-06-08T20:56:25Z

Should be straight foward to adjust the format to what you need ... this produces "2013-06-08T20:56:25Z"

SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
timeFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
String time = timeFormat.format(new Date());

这篇关于Java的公历,以特定的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆