Display local Ottawa time even when server is not in that timezone
[frank.git] / prod / net / jaekl / frank / Schedule.java
index c7fd70bfcd3a7b5ed991bdaf537b9bf762af6971..edd1b398a602afff7e23aa734d892ee5de6c8a1f 100644 (file)
@@ -6,6 +6,7 @@ import java.text.MessageFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
+import java.util.TimeZone;
 
 import net.jaekl.frank.octranspo.Route;
 import net.jaekl.frank.octranspo.StopInfo;
@@ -22,6 +23,14 @@ public class Schedule {
                m_bundle = FrankBundle.getInst(locale);
                m_hourMinFmt = new SimpleDateFormat("hh:mma", locale);
                m_hourMinSecFmt = new SimpleDateFormat("hh:mm:ssa", locale);
+               
+               // We always display times in Ottawa (local) time, because that's the only 
+               // time that makes sense for a user who wants to know when to catch a bus.
+               // In the (unlikely?) event that our server is in a different timezone,
+               // we need to explicitly specify the time zone that we want to use.
+               TimeZone tz = TimeZone.getTimeZone("America/Toronto");
+               m_hourMinFmt.setTimeZone(tz);
+               m_hourMinSecFmt.setTimeZone(tz);
        }
        
        String trans(String key) {