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

java.text.DateFormatSymbols.getZoneStrings returns array with m less than 5

XMLWordPrintable

    • b86
    • generic
    • generic

      the spec states:

      public String[][] getZoneStrings()
      ...
      The value returned is a two-dimensional array of strings of size n by m, where m is at least 5.

      a test text:
      --------------------
      import java.text.DateFormatSymbols;

      public class Test {

          public static void main( String[] args ){
              DateFormatSymbols obj = new DateFormatSymbols();
              String[][] zs = {
                  { "GMT", "AA", "BB" }
              };

              obj.setZoneStrings(zs);

              for( String[] s : obj.getZoneStrings() ){
                  if( s.length < 5 ){
                      System.out.println( "m = " + s.length );
                      System.out.println( "specification violation:\nThe value returned is a two-dimensional array of strings of size n by m, where m is at least 5." );
                      return;
                  }
              }
              System.out.println("OK");
          }
      }
      --------------------

      There are at least 3 ways to solve this problem:
      - to throw IllegalArgumentException in setZoneStrings()
      - appropriately modify array passed in setZoneStrings() before returning from getZoneStrings()
      - to change the spec

            naoto Naoto Sato
            itseytin Igor Tseytin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: