You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Colm O hEigeartaigh (JIRA)" <ji...@apache.org> on 2019/03/20 15:10:00 UTC
[jira] [Resolved] (CXFXJC-33) DataTypeAdapter parseDate resolving
as wrong date
[ https://issues.apache.org/jira/browse/CXFXJC-33?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Colm O hEigeartaigh resolved CXFXJC-33.
---------------------------------------
Resolution: Won't Fix
> 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)