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

Missing digits in millisecond format in SimpleDateFormat

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.1.6
    • core-libs
    • generic
    • generic



      Name: mf23781 Date: 06/12/98


      In the SimpleDateFormat only 3 didgits can be used for the millisecond field.
      The pattern I have is required for DB2 ISO Timestamp
      format. It requires 6 digits milliseconds. For now, I am forced
      to concatenate 3 zero and a single quote at the end before I can pass it
      to DB2, which I don't think is a correct way to do...

      NOTE: the ISOPattern consist two single quote at the beginning and the end
      of the pattern.
                **** Not double quote. *****


      Here is the code to reproduce the bug:

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

      class MillisecondTest
      {
      public static void main(String[] args)
      {
      new MillisecondTest();
      }

      MillisecondTest()
      {
      Date aGMTDate = new Date();
      String ISOPattern = "''yyyy-MM-dd-hh.mm.ss.SSSSSS''";
      SimpleDateFormat aSimpleDF = ( SimpleDateFormat)DateFormat.getDateTimeInstance();
      aSimpleDF.applyPattern( ISOPattern );
      System.out.println( "a Pattern = " + aSimpleDF.toPattern() );
      System.out.println( "a format = " + aSimpleDF.format( aGMTDate ) );
      }
      }

      Here is the Output:
       
      a Pattern = ''yyyy-MM-dd-hh.mm.ss.SSSSSS''
      a format = '1998-05-20-10.09.31.043'

      The expected output should be:

      a format = '1998-05-20-10.09.31.043000'
      Three digits from millisecond (S) field is missing.

      ======================================================================

            aliusunw Alan Liu (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: