[
https://issues.apache.org/jira/browse/CXFXJC-33?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16797252#comment-16797252
]
Colm O hEigeartaigh commented on CXFXJC-33:
-------------------------------------------
The Calendar example prints out the wrong date as well here: Tue Jul 31
00:00:00 IST 2018
I'm going to resolve this as "won't fix", as it's not a bug in CXF.
> DataTypeAdapter parseDate resolving as wrong date
> -------------------------------------------------
>
> Key: CXFXJC-33
> URL: https://issues.apache.org/jira/browse/CXFXJC-33
> Project: CXF XJC Utils
> Issue Type: Bug
> Reporter: S V Mohana Rao
> Priority: Major
>
> DataTypeAdapter parseDate interprets as wrong date instead of throwing
> exception.
> Though DataTypeAdapter uses javax.xml.bind.DatatypeConverter class but
> untimately it gives wrong results.
> Alternative approach : Use SimpleDateFormat having lenient set to false.
> dateFormatter.setLenient(false);
> {code:java}
> public class DataTypeAdapterTest {
> @Test
> public void testToString() throws Exception {
> Date date = DataTypeAdapter.parseDate("2018-06-31");
> System.out.println(date); //prints Sun Jul 01 00:00:00 IST 2018
> Assert.assertEquals(date.getTime(), getTestDate().getTime());
> }
> private static Date getTestDate() {
> Calendar eot = Calendar.getInstance();
> eot.set(Calendar.YEAR, 2018);
> eot.set(Calendar.MONTH, 06);
> eot.set(Calendar.DAY_OF_MONTH, 31);
> eot.set(Calendar.HOUR_OF_DAY, 0);
> eot.set(Calendar.MINUTE, 0);
> eot.set(Calendar.SECOND, 0);
> eot.set(Calendar.MILLISECOND, 0);
> return eot.getTime();
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)