You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Amila Chinthaka Suriarachchi (JIRA)" <ji...@apache.org> on 2008/02/05 07:49:07 UTC

[jira] Commented: (AXIS2-3489) Problem with ConverterUtil date conversion

    [ https://issues.apache.org/jira/browse/AXIS2-3489?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12565657#action_12565657 ] 

Amila Chinthaka Suriarachchi commented on AXIS2-3489:
-----------------------------------------------------

Please try with a nighly build. This bug is already fixed.

> Problem with ConverterUtil date conversion
> ------------------------------------------
>
>                 Key: AXIS2-3489
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3489
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: databinding
>    Affects Versions: 1.3
>         Environment: Linux OS and Java 5.0
>            Reporter: Shital Joshi
>
> When AXIS2 converts Date to String on client side (serialization), it attaches timezone 'Z' to date (And this is GMT timezone). So when server converts this String to Date (while parsing), because of GMT timezone (-5 hours from 12 AM), it becomes previous date. 
> For example:
> java.util.Date d = new SimpleDateFormat("yyyyMMdd").parse("20080124");
> System.out.println("d=" + d);
> System.out.println("d.toGMTString()=" + d.toGMTString());
> String d1 = org.apache.axis2.databinding.utils.ConverterUtil.convertToString(d);
> System.out.println("d1=" + d1);
> java.util.Date d2 = org.apache.axis2.databinding.utils.ConverterUtil.convertToDate(d1);
> System.out.println("d2=" + d2);
> System.out.println("d2.toGMTString()=" + d2.toGMTString());
> d=Thu Jan 24 00:00:00 EST 2008
> d.toGMTString()=24 Jan 2008 05:00:00 GMT
> d1=2008-01-24Z
> d2=Wed Jan 23 19:00:00 EST 2008
> d2.toGMTString()=24 Jan 2008 00:00:00 GMT
> This is current implementation of convertToString method in ConverterUtil class.
> public static String convertToString(Date value) {
> 	        // lexical form of the date is '-'? yyyy '-' mm '-' dd zzzzzz?
> 	        // we have to serialize it with the GMT timezone
> 	        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'Z'");
> 	        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
> 	        return simpleDateFormat.format(value);
> 	    }
> The developer should be able to set his own dateformat in this method.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org