← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17078: various tz fixes in calendar, instead of defaulting to utc for iso chronology, be explicit and se...

 

------------------------------------------------------------
revno: 17078
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-10-13 20:49:20 +0700
message:
  various tz fixes in calendar, instead of defaulting to utc for iso chronology, be explicit and set local tz (DateTimeUnit.toUtc is still available)
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/ChronologyBasedCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/CopticCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/EthiopianCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/GregorianCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/IslamicCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/Iso8601Calendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/JulianCalendar.java
  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/ThaiCalendar.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.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-09-21 07:49:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/AbstractCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import com.google.common.collect.Lists;
 import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.ISOChronology;
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
@@ -189,7 +190,7 @@
     @Override
     public DateTimeUnit today()
     {
-        DateTime dateTime = DateTime.now( ISOChronology.getInstance() );
+        DateTime dateTime = DateTime.now( ISOChronology.getInstance( DateTimeZone.getDefault() ) );
         DateTimeUnit dateTimeUnit = new DateTimeUnit( dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), true );
         return fromIso( dateTimeUnit );
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java	2014-09-22 04:51:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.joda.time.Chronology;
 import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
 import org.joda.time.LocalDate;
 import org.joda.time.chrono.ISOChronology;
 
@@ -56,7 +57,7 @@
         }
 
         DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
-        dateTime = dateTime.withChronology( ISOChronology.getInstance() );
+        dateTime = dateTime.withChronology( ISOChronology.getInstance( DateTimeZone.forTimeZone( dateTimeUnit.getTimeZone() ) ) );
 
         return new DateTimeUnit( DateTimeUnit.fromJodaDateTime( dateTime ), true );
     }
@@ -75,7 +76,7 @@
             return dateTimeUnit;
         }
 
-        DateTime dateTime = dateTimeUnit.toJodaDateTime( ISOChronology.getInstance() );
+        DateTime dateTime = dateTimeUnit.toJodaDateTime( ISOChronology.getInstance( DateTimeZone.forTimeZone( dateTimeUnit.getTimeZone() ) ) );
         dateTime = dateTime.withChronology( chronology );
 
         return DateTimeUnit.fromJodaDateTime( dateTime );
@@ -247,7 +248,7 @@
     public int isoWeekday( DateTimeUnit dateTimeUnit )
     {
         DateTime dateTime = dateTimeUnit.toJodaDateTime( chronology );
-        dateTime = dateTime.withChronology( ISOChronology.getInstance() );
+        dateTime = dateTime.withChronology( ISOChronology.getInstance( DateTimeZone.getDefault() ) );
         return dateTime.getDayOfWeek();
     }
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/CopticCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/CopticCalendar.java	2014-04-25 12:25:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/CopticCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.CopticChronology;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +49,7 @@
 
     protected CopticCalendar()
     {
-        super( CopticChronology.getInstance() );
+        super( CopticChronology.getInstance( DateTimeZone.getDefault() ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/EthiopianCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/EthiopianCalendar.java	2014-04-25 13:14:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/EthiopianCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.EthiopicChronology;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +49,7 @@
 
     protected EthiopianCalendar()
     {
-        super( EthiopicChronology.getInstance() );
+        super( EthiopicChronology.getInstance( DateTimeZone.getDefault() ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/GregorianCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/GregorianCalendar.java	2014-09-21 07:49:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/GregorianCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.GregorianChronology;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +49,7 @@
 
     protected GregorianCalendar()
     {
-        super( GregorianChronology.getInstance() );
+        super( GregorianChronology.getInstance( DateTimeZone.getDefault() ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/IslamicCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/IslamicCalendar.java	2014-04-25 12:25:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/IslamicCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.IslamicChronology;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +49,7 @@
 
     protected IslamicCalendar()
     {
-        super( IslamicChronology.getInstance() );
+        super( IslamicChronology.getInstance( DateTimeZone.getDefault() ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/Iso8601Calendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/Iso8601Calendar.java	2014-09-21 07:49:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/Iso8601Calendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.ISOChronology;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +49,7 @@
 
     protected Iso8601Calendar()
     {
-        super( ISOChronology.getInstance() );
+        super( ISOChronology.getInstance( DateTimeZone.getDefault() ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/JulianCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/JulianCalendar.java	2014-04-25 12:25:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/JulianCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.JulianChronology;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +49,7 @@
 
     protected JulianCalendar()
     {
-        super( JulianChronology.getInstance() );
+        super( JulianChronology.getInstance( DateTimeZone.getDefault() ) );
     }
 
     @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-09-22 04:51:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/NepaliCalendar.java	2014-10-13 13:49:20 +0000
@@ -34,6 +34,7 @@
 import org.hisp.dhis.calendar.DateIntervalType;
 import org.hisp.dhis.calendar.DateTimeUnit;
 import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
 import org.joda.time.Days;
 import org.joda.time.chrono.ISOChronology;
 import org.springframework.stereotype.Component;
@@ -233,14 +234,14 @@
     @Override
     public int weeksInYear( int year )
     {
-        DateTime dateTime = new DateTime( year, 1, 1, 0, 0, ISOChronology.getInstance() );
+        DateTime dateTime = new DateTime( year, 1, 1, 0, 0, ISOChronology.getInstance( DateTimeZone.getDefault() ) );
         return dateTime.weekOfWeekyear().getMaximumValue();
     }
 
     @Override
     public int isoWeek( DateTimeUnit dateTimeUnit )
     {
-        DateTime dateTime = toIso( dateTimeUnit ).toJodaDateTime( ISOChronology.getInstance() );
+        DateTime dateTime = toIso( dateTimeUnit ).toJodaDateTime( ISOChronology.getInstance( DateTimeZone.getDefault() ) );
         return dateTime.getWeekyear();
     }
 
@@ -253,7 +254,7 @@
     @Override
     public int isoWeekday( DateTimeUnit dateTimeUnit )
     {
-        DateTime dateTime = toIso( dateTimeUnit ).toJodaDateTime( ISOChronology.getInstance() );
+        DateTime dateTime = toIso( dateTimeUnit ).toJodaDateTime( ISOChronology.getInstance( DateTimeZone.getDefault() ) );
         return dateTime.getDayOfWeek();
     }
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/ThaiCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/ThaiCalendar.java	2014-04-27 15:25:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/impl/ThaiCalendar.java	2014-10-13 13:49:20 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.calendar.Calendar;
 import org.hisp.dhis.calendar.ChronologyBasedCalendar;
+import org.joda.time.DateTimeZone;
 import org.joda.time.chrono.BuddhistChronology;
 import org.springframework.stereotype.Component;
 
@@ -48,7 +49,7 @@
 
     protected ThaiCalendar()
     {
-        super( BuddhistChronology.getInstance() );
+        super( BuddhistChronology.getInstance( DateTimeZone.getDefault() ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java	2014-10-13 12:31:18 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/CompleteDataSetRegistrationController.java	2014-10-13 13:49:20 +0000
@@ -67,9 +67,7 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Date;
-import java.util.GregorianCalendar;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;