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

DateFormat getDateTimeInstance(int, int) w/ invalid styles no exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.3.0
    • 1.1.7
    • core-libs
    • None
    • beta
    • sparc
    • solaris_2.6

      DateFormat getDateInstance, getDateTimeInstance, getTimeInstance methods
      do not always throw IllegalArgumentException when the style is invalid.
      The methods should throw IllegalArgumentException when the style value is not
      a valid value (style != SHORT, MEDIUM, LONG, FULL, DEFAULT).

      Some examples:
      --------
      DateFormat df = DateFormat.getDateTimeInstance(4, 2);
      System.out.println("Date: " + df.format(someDate));
        Date: {1} {0} 11:36:41 AM
      --------
      DateFormat df = DateFormat.getDateTimeInstance(2, -1);
      System.out.println("Date: " + df.format(someDate));
        Date: 19-Feb-99
      --------
      DateFormat df = DateFormat.getDateTimeInstance(2, 123);
        java.lang.ArrayIndexOutOfBoundsException: 123
      at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java)
      at java.text.DateFormat.get(DateFormat.java)
      at java.text.DateFormat.getDateTimeInstance(DateFormat.java)
      at getDateTimeInstanceTests.Test04(getDateTimeInstanceTests.java:220)
      at getDateTimeInstanceTests.main(getDateTimeInstanceTests.java:63)
      --------
      DateFormat df = DateFormat.getDateTimeInstance(-12, -12);
        java.lang.IllegalArgumentException: No date or time style specified
      at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java)
      at java.text.DateFormat.get(DateFormat.java)
      at java.text.DateFormat.getDateTimeInstance(DateFormat.java)
      at getDateTimeInstanceTests.Test03(getDateTimeInstanceTests.java:186)
      at getDateTimeInstanceTests.main(getDateTimeInstanceTests.java:60)



            aliusunw Alan Liu (Inactive)
            mcolburnsunw Michael Colburn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: