XMLGregorianCalendar Date Convert

cxf等生成webservice会自动将Date类型转换为XMLGregorianCalendar。这两种类型之间的转换如下:

1.  XMLGregorianCalendar xgc;

Calendar calendar = Calendar.getInstance();
calendar.set(xgc.getYear(), xgc.getMonth(),

xgc.getDay(), xgc.getHour(), xgc.getMinute(), xgc.getSecond());
Date date = calendar.getTime();

2. xgc.toGregorianCalendar().getTime();

//参考:1. http://stackoverflow.com/questions/3679266/simple-conversion-between-java-util-date-and-xmlgregoriancalendar

2. http://blog.csdn.net/fengyun111999/article/details/5943648

This entry was posted in Computer, Java. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s