← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18474: applied patch from TW, adds full date+time info when exporting data values

 

------------------------------------------------------------
revno: 18474
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-03-04 17:13:19 +0700
message:
  applied patch from TW, adds full date+time info when exporting data values
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.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-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/SpringDataValueSetStore.java	2015-03-04 10:13:19 +0000
@@ -54,7 +54,7 @@
 import java.util.Set;
 
 import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdentifiers;
-import static org.hisp.dhis.system.util.DateUtils.getLongDateString;
+import static org.hisp.dhis.system.util.DateUtils.getLongGmtDateString;
 import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
 
 /**
@@ -134,7 +134,7 @@
         OrganisationUnit orgUnit, final DataValueSet dataValueSet )
     {
         dataValueSet.setDataSet( (dataSets != null && dataSets.size() == 1) ? dataSets.iterator().next().getUid() : null );
-        dataValueSet.setCompleteDate( getLongDateString( completeDate ) );
+        dataValueSet.setCompleteDate( getLongGmtDateString( completeDate ) );
         dataValueSet.setPeriod( period != null ? period.getIsoDate() : null );
         dataValueSet.setOrgUnit( orgUnit != null ? orgUnit.getUid() : null );
 
@@ -155,8 +155,8 @@
                 dataValue.setAttributeOptionCombo( rs.getString( "aocid" ) );
                 dataValue.setValue( rs.getString( "value" ) );
                 dataValue.setStoredBy( rs.getString( "storedby" ) );
-                dataValue.setCreated( getLongDateString( rs.getDate( "created" ) ) );
-                dataValue.setLastUpdated( getLongDateString( rs.getDate( "lastupdated" ) ) );
+                dataValue.setCreated( getLongGmtDateString( rs.getTimestamp( "created" ) ) );
+                dataValue.setLastUpdated( getLongGmtDateString( rs.getTimestamp( "lastupdated" ) ) );
                 dataValue.setComment( rs.getString( "comment" ) );
                 dataValue.setFollowup( rs.getBoolean( "followup" ) );
                 dataValue.close();

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java	2015-03-04 09:47:54 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java	2015-03-04 10:13:19 +0000
@@ -41,6 +41,7 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
+import java.util.TimeZone;
 
 import static org.hisp.dhis.period.Period.DEFAULT_DATE_FORMAT;
 
@@ -68,6 +69,7 @@
     public static final SimpleDateFormat ACCESS_DATE_FORMAT = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" );
     public static final SimpleDateFormat HTTP_DATE_FORMAT = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss" );
 
+
     public static final double DAYS_IN_YEAR = 365.0;
 
     private static final long MS_PER_DAY = 86400000;
@@ -85,6 +87,25 @@
     }
 
     /**
+     * Converts a Date to the GMT timezone and formats it to the format yyyy-MM-dd HH:mm:ssZ.
+     *
+     * @param date the Date to parse.
+     * @return A formatted date string.
+     */
+    public static String getLongGmtDateString( Date date )
+    {
+        if ( date == null )
+        {
+            return null;
+        }
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSZ" );
+        simpleDateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
+        return simpleDateFormat.format( date );
+    }
+
+
+    /**
      * Formats a Date to the format yyyy-MM-dd HH:mm:ss.
      *
      * @param date the Date to parse.