Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: yyT116575 Date: 05/23/2001 java version "1.3.1" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24) Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode) I found the different result when using FORMAT method in java.text.SimpleDateFormat of JDK1.1.8 and JDK1.3.1. Result after formatting current date to "HHmmssSS" from beneath program - Using JDK1.1.8 has the same length (8). - Using JDK1.3.1 has not the same length (8 or 9). -------------------------------------------------------------------------------- import java.text.SimpleDateFormat; import java.util.*; // There is different when we converts date using FormatDateTime by JDK1.1.8 and JDK1.3.1 class TestFormatDate { private static String FORMAT = "HHmmssSS"; public static void main(String args[]) throws Throwable { for (int i=0; i < 10; i++) { Date d = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(FORMAT); String formatS = sdf.format(d); System.out.println("Format [" + formatS + ", " + formatS.length() + "]"); double rand = Math.random(); Thread.sleep(Math.round(rand * 100)); } } } -------------------------------------------------------------------------------- Result from JDK1.1.8 Format [16170253, 8] Format [16170259, 8] Format [16170266, 8] Format [16170271, 8] Format [16170276, 8] Format [16170286, 8] Format [16170297, 8] Format [16170302, 8] Format [16170307, 8] Format [16170312, 8] Result from JDK1.3.1 Format [160505643, 9] Format [160505828, 9] Format [160505918, 9] Format [16050618, 8] Format [16050668, 8] Format [160506128, 9] Format [160506148, 9] Format [160506198, 9] Format [160506218, 9] Format [160506238, 9] (Review ID: 124873) ======================================================================
|