← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15015: basic date formatting for calendar that doesn't care about validity of date (needed for nepali ca...

 

------------------------------------------------------------
revno: 15015
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 14:48:54 +0545
message:
  basic date formatting for calendar that doesn't care about validity of date (needed for nepali calendar), only supports yyyy, MM, and dd
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.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-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java	2014-04-27 08:47:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java	2014-04-27 09:03:54 +0000
@@ -99,10 +99,10 @@
     @Override
     public String formattedDate( DateUnit dateUnit )
     {
-        DateTime dateTime = dateUnit.toDateTime();
-        DateTimeFormatter format = DateTimeFormat.forPattern( defaultDateFormat() );
-
-        return format.print( dateTime );
+        return defaultDateFormat()
+            .replace( "yyyy", String.format( "%04d", dateUnit.getYear() ) )
+            .replace( "MM", String.format( "%02d", dateUnit.getMonth() ) )
+            .replace( "dd", String.format( "%02d", dateUnit.getDay() ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java	2014-04-27 08:49:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java	2014-04-27 09:03:54 +0000
@@ -64,13 +64,6 @@
         return "nepali";
     }
 
-    // TODO Add proper local date format for Nepali, can't use default.. since the month numbers are outside the valid ISO 8601 range
-    @Override
-    public String formattedDate( DateUnit dateUnit )
-    {
-        return super.formattedDate( dateUnit );
-    }
-
     @Override
     public DateUnit toIso( DateUnit dateUnit )
     {