Menu

Fix day labels and Time Zone

Help
2006-10-11
2013-04-11
  • Vito Impagliazzo

    I've been fixing the DatePicker to display the correct day labels when in different Locale and also use the right time zone when we invoke DatePickerCombo.setFormat() using a formatter which uses a different TimeZone. Here are the diffs:

    diff src/com/tiff/common/ui/datepicker/DatePicker.java ../util/com/tiff/common/ui/datepicker/DatePicker.java
    5a6
    > import java.util.TimeZone;
    275c276,300
    <                               drawTextImage(gc, getDayName(1 + i), x, 0, colSize, rowSize);
    ---
    >                               int day;
    >                               switch (i) {
    >                               case 0:
    >                                       day = Calendar.MONDAY;
    >                                       break;
    >                               case 1:
    >                                       day = Calendar.TUESDAY;
    >                                       break;
    >                               case 2:
    >                                       day = Calendar.WEDNESDAY;
    >                                       break;
    >                               case 3:
    >                                       day = Calendar.THURSDAY;
    >                                       break;
    >                               case 4:
    >                                       day = Calendar.FRIDAY;
    >                                       break;
    >                               case 5:
    >                                       day = Calendar.SATURDAY;
    >                                       break;
    >                               default:
    >                                       day = Calendar.SUNDAY;
    >                                       break;
    >                               }
    >                               drawTextImage(gc, getDayName(day), x, 0, colSize, rowSize);
    331a357
    >       private TimeZone timeZone;
    491a518,519
    >               if ( timeZone != null )
    >                       cal.setTimeZone(timeZone);
    503a532,537
    >
    >       public void setTimeZone(TimeZone zone) {
    >               datePanel.temp.setTimeZone(zone);
    >               cal.setTimeZone(zone);
    >               timeZone = zone;
    >       }

    diff src/com/tiff/common/ui/datepicker/DatePickerCombo.java ../util/com/tiff/common/ui/datepicker/DatePickerCombo.java
    2a3,6
    > import java.text.DateFormat;
    > import java.text.ParseException;
    > import java.util.Date;
    >
    3a8
    > import org.eclipse.swt.SWTError;
    24,29d28
    < import java.text.DateFormat;
    < import java.text.ParseException;
    < import java.text.SimpleDateFormat;
    <
    < import java.util.Date;
    <
    799a799
    >       dp.setTimeZone(format.getTimeZone());

     
    • oleg_ryaboy

      oleg_ryaboy - 2006-10-30

      Awesome! Could you post the changes as a patch?

      Thanks!

       

Log in to post a comment.