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

Timestamp.valueOf(LocalDateTime) should throw when conversion is not possible

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u25
    • core-libs
    • x86_64
    • linux_ubuntu

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      Timestamp.valueOf(LocalDateTime) argument may represent dateTime that couldn't be converted to Timestamp.

      Timestamp.valueOf(LocalDateTime.MIN)
      gives 169087565-03-15 04:51:43.0.
      - should throw IllegalArgumentException.

      Timestamp.valueOf(LocalDateTime.MAX)
      gives 169104628-12-10 19:08:15.999999999
      - should throw IllegalArgumentException.

      Please fix javadoc too.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      new Timestamp(LocalDateTime.MIN.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());

      new Timestamp(LocalDateTime.MAX.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());


            lancea Lance Andersen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: