dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32245
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16466: match xml date format to json (jackson) default output format
------------------------------------------------------------
revno: 16466
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-08-21 16:10:25 +0700
message:
match xml date format to json (jackson) default output format
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java 2014-07-18 13:32:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java 2014-08-21 09:10:25 +0000
@@ -44,7 +44,10 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
+import java.util.TimeZone;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -108,6 +111,13 @@
{
String value = String.format( "%s", simpleNode.getValue() );
+ if ( Date.class.isAssignableFrom( simpleNode.getValue().getClass() ) )
+ {
+ SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" );
+ dateFormat.setTimeZone( TimeZone.getTimeZone("UTC") );
+ value = dateFormat.format( (Date) simpleNode.getValue() );
+ }
+
if ( simpleNode.isAttribute() )
{
if ( !StringUtils.isEmpty( simpleNode.getNamespace() ) )