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.
======================================================================
- relates to
-
JDK-4462302 Different result from FORMAT method in java.text.SimpleDateFormat
-
- Closed
-