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

java.sql.Date.valueOf no exception if date given is not in the JDBC date escape format(yyyy-mm-dd)

    Details

    • Subcomponent:
    • Introduced In Build:
      1.1
    • Introduced In Version:
      1.1
    • Resolved In Build:
      b09
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Backports

        Description

        As per the API doc for java.sql.Date.valueOf, IllegalArgumentException should
        be thrown if the date given is not in the JDBC date escape format
        (yyyy-mm-dd).
         
        The error is not thrown when I enter the value '20009-10-10'. Instead it
        silently stores the value. But later when I do java.sql.toString()
         
            public static void main(String[] args) {
                java.sql.Date jsd = java.sql.Date.valueOf("20009-06-26");
                System.out.println(jsd);
         
            }



         
        The above program prints
        *009-06-26 Where '*' is a non-readable character.

        We need fix in valueOf method() to throw the exception if we pass 5 digits to
        the API.

        From API
        valueOf

        public static Date valueOf(String s)

            Converts a string in JDBC date escape format to a Date value.

            Parameters:
                s - a String object representing a date in in the format "yyyy-mm-dd"
            Returns:
                a java.sql.Date object representing the given date
            Throws:
                IllegalArgumentException - if the date given is not in the JDBC date escape format (yyyy-mm-dd)

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  minqi Yumin Qi
                  Reporter:
                  dvanero Dennis Van Eron
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: