That did not work due to empty formatting strings. This seems to work
better

=== modified file 'dhis-2/dhis-api/pom.xml'
--- dhis-2/dhis-api/pom.xml     2011-03-02 00:23:51 +0000
+++ dhis-2/dhis-api/pom.xml     2011-04-09 06:39:39 +0000
@@ -34,9 +34,13 @@
       <groupId>net.sf.jasperreports</groupId>
       <artifactId>jasperreports</artifactId>
     </dependency>
+       <dependency>
+    <groupId>joda-time</groupId>
+    <artifactId>joda-time</artifactId>
+    <version>1.6.2</version>
+       </dependency>
   </dependencies>
-
-  <properties>
+    <properties>
     <rootDir>../</rootDir>
   </properties>
 </project>

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.j
ava'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java    2011-03-
20 13:57:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java    2011-04-
09 08:54:49 +0000
@@ -34,9 +34,13 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.ResourceBundle;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.DateTime;

 import org.hisp.dhis.period.Period;

+
 /**
  * @author Pham Thi Thuy
  * @author Nguyen Dang Quang
@@ -49,6 +53,7 @@
     private static final String NAN = "NaN";

     private ResourceBundle resourceBundle;
+

     public I18nFormat( ResourceBundle resourceBundle )
     {
@@ -236,8 +241,24 @@

     private String commonFormatting( Date date, String pattern )
     {
-        DateFormat dateFormat = new SimpleDateFormat( pattern, dateFormatSymbol
s );
+        log.info("pattern_input " + pattern);
+        DateTime dt = new DateTime(date);
+        String formattedDateString;

-        return dateFormat.format( date );
+        if (  pattern.isEmpty() )
+        {
+            return EMPTY;
+
+        }
+        try
+        {
+        DateTimeFormatter fmt = DateTimeFormat.forPattern( pattern );
+        formattedDateString = fmt.print( dt );
+        }
+        catch ( IllegalArgumentException e)
+        {
+            return EMPTY;
+        }
+        return formattedDateString;
     }
 }


On Sat, Apr 9, 2011 at 9:25 AM, jason.p.pickering
<754...@bugs.launchpad.net> wrote:
> Tested this potential fix against trunk. I altered the commonFormatting 
> method of I18nFormat.java, replacing the SimpleDateFormat with an equivalent 
> formatter from the JODA library.
>
>  I do not think the periods themselves are off, only the formatting.
>
> Works for me (at least with superficial testing) on  rev. 3326 and the
> week numbers seem to be correct in the Data Entry screen.
>
>
>
> ** Attachment added: "week_patch.txt"
>   
> https://bugs.launchpad.net/dhis2/+bug/754480/+attachment/2004433/+files/week_patch.txt
>
> --
> You received this bug notification because you are a member of DHIS 2
> India Developers, which is subscribed to DHIS.
> https://bugs.launchpad.net/bugs/754480
>
> Title:
>  Week number incorrect
>
> Status in DHIS 2 - District Health Information Software:
>  Confirmed
>
> Bug description:
>  DHIS reports the first week of 2011 as starting on 3 January 2011.
>  This is in fact the beginning of week 2 (2010W2).
>


-- 
Jason P. Pickering
email: jason.p.picker...@gmail.com
tel:+260974901293

-- 
You received this bug notification because you are a member of DHIS 2
developers, which is subscribed to DHIS.
https://bugs.launchpad.net/bugs/754480

Title:
  Week number incorrect

Status in DHIS 2 - District Health Information Software:
  Confirmed

Bug description:
  DHIS reports the first week of 2011 as starting on 3 January 2011.
  This is in fact the beginning of week 2 (2010W2).

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Reply via email to