← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19404: support fractions in DateUtils date patterns

 

------------------------------------------------------------
revno: 19404
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-06-15 11:15:16 +0700
message:
  support fractions in DateUtils date patterns
modified:
  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-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-06-10 01:03:19 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/DateUtils.java	2015-06-15 04:15:16 +0000
@@ -54,9 +54,12 @@
 {
     private static final DateTimeParser[] SUPPORTED_DATE_FORMAT_PARSERS = {
             DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ").getParser(),
+            DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").getParser(),
             DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").getParser(),
             DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").getParser(),
+            DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mmZ").getParser(),
             DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm").getParser(),
+            DateTimeFormat.forPattern("yyyy-MM-dd'T'HHZ").getParser(),
             DateTimeFormat.forPattern("yyyy-MM-dd'T'HH").getParser(),
             DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ssZ").getParser(),
             DateTimeFormat.forPattern("yyyy-MM-dd").getParser(),
@@ -68,7 +71,7 @@
             .append( null, SUPPORTED_DATE_FORMAT_PARSERS ).toFormatter();
 
     private static final String SEP = ", ";
-    
+
     public static final PeriodFormatter DAY_SECOND_FORMAT = new PeriodFormatterBuilder()
         .appendDays().appendSuffix( " d" ).appendSeparator( SEP )
         .appendHours().appendSuffix( " h" ).appendSeparator( SEP )
@@ -80,15 +83,15 @@
     /**
      * Used by web API and utility methods.
      */
-    public static final String DATE_PATTERN = "yyyy-MM-dd";    
+    public static final String DATE_PATTERN = "yyyy-MM-dd";
     public static final String TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
-    
+
     public static final SimpleDateFormat LONG_DATE_FORMAT = new SimpleDateFormat( TIMESTAMP_PATTERN );
     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;
     private static final long MS_PER_S = 1000;
 
@@ -157,10 +160,10 @@
 
         return date != null ? format.format( date ) : null;
     }
-    
+
     /**
      * Returns the latest of the two given dates.
-     * 
+     *
      * @param date1 the first date.
      * @param date2 the second date.
      * @return the latest of the two given dates.
@@ -171,25 +174,25 @@
         {
             return date2 != null ? date2 : null;
         }
-        
-        return date2 != null ? ( date1.after( date2 ) ? date1 : date2 ) : date1;        
+
+        return date2 != null ? ( date1.after( date2 ) ? date1 : date2 ) : date1;
     }
 
     /**
      * Returns the latest of the given dates.
-     * 
+     *
      * @param date the dates.
      * @return the latest of the given dates.
      */
     public static Date max( Date... date )
     {
         Date latest = null;
-        
+
         for ( Date d : date )
         {
             latest = max( d, latest );
         }
-        
+
         return latest;
     }
 
@@ -584,11 +587,11 @@
 
         return periods;
     }
-    
+
     /**
      * Returns a pretty string representing the interval between the given
      * start and end dates using a day, month, second format.
-     * 
+     *
      * @param start the start date.
      * @param end the end date.
      * @return a string, or null if the given start or end date is null.
@@ -599,9 +602,9 @@
         {
             return null;
         }
-        
+
         long diff = end.getTime() - start.getTime();
-        
+
         return DAY_SECOND_FORMAT.print( new org.joda.time.Period( diff ) );
     }