xmlgregoriancalendar格式化在MM / dd / yyyy [英] xmlgregoriancalendar formatting in MM/dd/yyyy

查看:1016
本文介绍了xmlgregoriancalendar格式化在MM / dd / yyyy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个格式为 MM / dd / yyyy 的类型日期变量。我需要以相同的格式将tempdate转换为xmlgregoriancalendar类型,即 MM / dd / yyyy

I have a variable of type date in the format MM/dd/yyyy. I need to convert the tempdate to xmlgregoriancalendar type in the same format i.e., MM/dd/yyyy.

使用 newxmlgregoriancalendarDate()创建时的默认格式是 yyyy-MM-dd
所以我无法转换它到 MM / dd / yyyy 类型为xmlgregoriancalendar的格式

The default format when created using newxmlgregoriancalendarDate() is yyyy-MM-dd so i am unable to convert it to MM/dd/yyyy format of type xmlgregoriancalendar

如何实现这一点?

推荐答案

XMLGregorianCalendar 不是真的拥有格式 - 相反,它不是对象中的数据,因为日期/时间的XML格式是特定的指定的格式。所以请求我需要将tempdate转换为相同格式的xmlgregoriancalendar类型,即MM / dd / yyyy没有任何意义,真的。

XMLGregorianCalendar doesn't really "have" a format - or rather, it's not part of the data in the object, because the XML format for dates/times is specified in a particular format. So the request of "I need to convert the tempdate to xmlgregoriancalendar type in the same format i.e., MM/dd/yyyy" makes no sense, really.

如果你想要获得一个不同的文本表示作为字符串,我建议您使用 toGregorianCalendar() 获取 java.util.Calendar - 那么你可以得到 java.util.Date 并使用适当构造的 SimpleDateFormat 来进行格式化。

If you want to get a different textual representation as a string, I suggest you use toGregorianCalendar() to get a java.util.Calendar - then you can get the java.util.Date and use an appropriately constructed SimpleDateFormat to do the formatting.

这篇关于xmlgregoriancalendar格式化在MM / dd / yyyy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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