Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4060495

Time is Being Changed with Locale Change when using DateFromat

XMLWordPrintable

    • generic, sparc
    • generic, solaris_2.6

      This problem duplicated on both Windows NT 4.0 running JDK 1.1.2 and Solaris running JDK 1.1.1A.

      To duplicat this problme run the following code.


      import java.text.DateFormat;
      import java.util.Date;
      import java.util.Locale;

      public class DateTest{
          
      public DateTest(){}

      public static void main(String args[]){
          Date testDate = new Date (97, 9-1, 15);
          DateFormat dfFrench = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, Locale.FRENCH);
          DateFormat dfUS = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, Locale.US);
          System.out.println("Date set to : " + testDate);
          System.out.println("Date Formated with French Locale " + dfFrench.format(testDate));
          System.out.println("Date Formated with US Locale " + dfUS.format(testDate));
      }
      }


      Output:

      Date set to : Mon Sep 15 00:00:00 PDT 1997
      Date Formated with French Locale lundi, 15 septembre 1997 09:00:00
      Date Formated with US Locale Monday, September 15, 1997 12:00:00 AM


      When a static date is set shouldn't the same time be returned for both Locales? For example if I was in France working with a US Locale setting I would get a complete different time.

      I have tried changing the TimeZone and Locale environment varibles in Windows NT 4.0 with a Japanese Locale and I was still experiencing the same problem problem. In that case the same date is returned but the time is 8:00 AM for the same date that returned 12:00am with the Locale and Regional settings set to US.

            ssenthilsunw Shanmugam Senthil (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: