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

format method of SimpleDateFormat class, for fr locale, returns timezone as "TU"

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      rc
    • CPU:
      x86
    • OS:
      generic
    • Verification:
      Verified

      Description

      format method of SimpleDateFormat class in case of fr locale,
      when time zone is set as "GMT" returns "TU" instead of "GMT".
      It is not the case if time zone is srt as "GMT+00:00"

      Mentiond below is the program and output too.

       import java.text.*;
       import java.util.*;


       class BugTest {

           public static void main(String args[]) throws Exception {
               
               DateFormat df = DateFormat.getDateTimeInstance();
               Locale[] loc = df.getAvailableLocales();
               String[] tzones = {"GMT", "GMT+00:00","GMT-00:00", "GMT+02:40"};
               boolean pass = true;

               for(int k=0; k<tzones.length; k++) {

                   for(int i=0; i<loc.length;i++) {
                       Locale.setDefault(loc[i]);
                       TimeZone tz1 = TimeZone.getTimeZone(tzones[k]);
                    // System.out.println(loc[i]);
                       SimpleDateFormat sdf = new SimpleDateFormat("M/d/yyyy z");
                       sdf.setTimeZone(tz1);
                       String datebuf = (sdf.format(new Date(),new StringBuffer(),new FieldPosition(0))).toString();
                   // System.out.println("Formatted-date :"+datebuf);
                   // System.out.println("Time-zone: "+tzones[k]);
                       if(datebuf.indexOf("GMT")==-1) {
                           System.out.println("Test failed for Locale :"+loc[i]);
                           System.out.println("Time-zone: "+tzones[k]);
                           System.out.println("Formatted-date :"+datebuf);
                           pass=false;
                       }
                   }
               }
           
               if(pass) {
                   System.out.println("Test Passed");
                   }
           
           
           
           }


       }

      **********Output******************************

      Test failed for Locale :fr
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_BE
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_BE_EURO
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_CA
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_CH
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_FR
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_FR_EURO
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_LU
      Time-zone: GMT
      Formatted-date :10/3/2001 TU
      Test failed for Locale :fr_LU_EURO
      Time-zone: GMT
      Formatted-date :10/3/2001 TU

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kcolfersunw Kieran Colfer (Inactive)
              Reporter:
              jsinghsunw Jit Singh (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: