-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
beta
-
generic
-
generic
Name: tb29552 Date: 09/13/2000
/*
Version independent
It seems ridiculous that java.util.Date (and anything using it) has to depend
on java.awt.ComponentOrientation just to get a constant for a Locale field.
Surely this is inside-out, and "pollutes" an otherwise reasonably "vertical"
package model. (Although I would prefer the Date 'numerics' to be separated
from the 'display/locale specific' side.)
The Locale should define some "text-direction" type properties, and then the
AWT package should use those at the appropriate times.
This makes much more sense!
*/
//Begin DataParse.java
//Based on sample code taken from this web page:
//http://java.sun.com/products/jdk/1.1/docs/api/java.text.SimpleDateFormat.html
import java.util.Calendar;
import java.util.TimeZone;
import java.util.SimpleTimeZone;
import java.util.Locale;
import java.text.DateFormat;
class DateParse {
public static void main(String[] args) {
java.util.TimeZone tsz = TimeZone.getTimeZone("GMT");
java.util.TimeZone.setDefault(tsz);
// Format the current time a few different ways:
java.text.SimpleDateFormat formatter =
new java.text.SimpleDateFormat ("yyyy.MM.dd 'at' HH:mm:ss a zzz");
java.util.Date currentTime_1 = new java.util.Date();
System.out.println("\n");
String dateString1 = formatter.format(currentTime_1);
// Parse the previous string back into a Date.
java.text.ParsePosition pos = new java.text.ParsePosition(0);
java.util.Date currentTime_2 = formatter.parse(dateString1, pos);
System.out.println("currentTime_1\tis: " + currentTime_1);
System.out.println("dateString1\tis: " + dateString1);
System.out.println("currentTime_2\tis: " + currentTime_2);
System.out.println("\n");
String [] dateStrings = {
"2000.05.19 at 21:22:00 PM GMT",
"1900.01.01 at 00:00:00 AM GMT",
"1900.01.01 at 08:00:00 AM GMT",
"1960.12.31 at 00:00:00 AM GMT", /* "1969-12-31 16:00:00.0" ???? */
"1900.01.01 at 00:00:01 AM GMT"};
// Parse several strings back into a Date & print the results.
for (int i = 0; i < dateStrings.length; i++) {
pos = new java.text.ParsePosition(0);
java.util.Date currentTime1 = formatter.parse(dateStrings[i], pos);
System.out.println("dateStrings[i]\tis: " + dateStrings[i]);
System.out.println("currentTime1\tis: " + currentTime1);
System.out.println("currentTime1 in milliseconds is: " + currentTime1.getTime());
System.out.println("\n");
}
}
}
//end DataParse.java
% javac DateParse.java
% java -verbose DateParse | grep awt
[Loaded java.awt.ComponentOrientation from /usr/local/java/jdk1.3.0-solaris-b28/solaris/jre/lib/rt.jar]
(Review ID: 109574)
======================================================================
- relates to
-
JDK-4418738 ComponentOrientation causes unnecessary class loads
-
- Resolved
-