-
Bug
-
Resolution: Fixed
-
P3
-
1.2.2
-
rc
-
generic
-
generic
-
Verified
Name: boT120536 Date: 12/05/2000
java version "1.2.2"
Classic VM (build 1.2.2-L, green threads, nojit)
I believe this is version-independent and is present in even
the newest version of JAVA.
1. Run the program below.
2. The program
---------Cut---------Here----------------
import java.io.*;
import java.text.*;
import java.util.*;
public class DateFormat2
{
public static void main(String[] arg)
{
String encoding = "EUCKR";
Locale loc = new Locale("ko","KR");
if ( arg.length == 3 ) {
loc = new Locale(arg[0],arg[1]);
encoding = arg[2];
}
else if (arg.length == 2) {
loc = new Locale(arg[0],"");
encoding = arg[1];
}
else if (arg.length == 1) {
loc = new Locale(arg[0],"");
}
try
{
OutputStreamWriter out1 = new OutputStreamWriter
(System.out, encoding );
PrintWriter out = new PrintWriter(out1);
Date now = new Date();
DateFormat df =
DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
DateFormat.DEFAULT,
loc);
String s = df.format(now);
out.println(s);
df =
DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL,
loc);
s = df.format(now);
out.println(s);
df =
DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.LONG,
loc);
s = df.format(now);
out.println(s);
df =
DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.FULL,
loc);
s = df.format(now);
out.println(s);
df =
DateFormat.getDateTimeInstance(DateFormat.SHORT,
DateFormat.SHORT,
loc);
s = df.format(now);
out.println(s);
}
catch (IOException e)
{ System.out.println("Error" + e); }
}
}
---------------Cut--------Here---------------------
3. The result from the above program
a. the result in JAVA \uxxx notation
---------Cut-------Here-----------
2000-11-13 \uc624\ud6c4 8:26:49
2000\ub144 11\uc6d4 13\uc77c \uc6d4\uc694\uc77c 08\uc2dc26\ubd8449\ucd08 \uc624\ud6c4 GMT-05:00
2000\ub144 11\uc6d4 13\uc77c \uc6d4 08\uc2dc26\ubd8449\ucd08 \uc624\ud6c4
2000-11-13 08\uc2dc26\ubd8449\ucd08 \uc624\ud6c4 GMT-05:00
00-11-13 \uc624\ud6c4 8:26
---------Cut-------Here-----------
b. the result is in EUC-KR encoding
---------Cut-------Here-----------
2000-11-13 ???? 8:26:49
2000?? 11?? 13?? ?????? 08??26??49?? ???? GMT-05:00
2000?? 11?? 13?? ?? 08??26??49?? ????
2000-11-13 08??26??49?? ???? GMT-05:00
00-11-13 ???? 8:26
---------Cut-------Here-----------
4. What's wrong with the above?
In what follows, 'M' and 'd' denote month and day of the month
in decimal numbers WITHOUT leading '0'.
a. The DEFAULT,MEDIUM and SHORT format for Date should be
YYYY. M. d
YYYY. M. d
YY. M. d
instead of
YYYY-MM-dd
YYYY-MM-dd
YY-MM-dd
We do NOT use ISO 8601 style date format. Instead we delimete
year,month and day with '. ' (period and space)
We do NOT zero-fill if month or day is a single digit number.
b. The FULL and LONG format for Time should be
am_pm h'\uC2DC' m'\uBD84' s'\uCD08' timezone
am_pm h'\uC2DC' m'\uBD84' s'\uCD08'
instead of
hh'\uC2DC'mm'\uBD84'ss'\uCD08' am_pm timezone
hh'\uC2DC'mm'\uBD84'ss'\uCD08' am_pm
Please, note that there should be SPACE(\u0020) after
'\uC2DC' and '\uBD84'.
am_pm should come before TIME NOT after TIME.
We do NOT zero-fill if hour,minute, or second is a single digit number.
c. In the LONG date format, ab_wk_day had better be enclosed with
'(' and ')'. That is, it's better to have
yyyy'\uB144' M`\uC6D4` d`\uC77C' (ab_wk_day)
than
yyyy'\uB144' M`\uC6D4` d`\uC77C' ab_wk_day
5. Expected result after the correction
a. in JAVA \uxxxx notation
--------Cut--------Here----------
2000. 11. 13 \uc624\ud6c4 8:26:49
2000\ub144 11\uc6d4 13\uc77c \uc6d4\uc694\uc77c \uc624\ud6c4 8\uc2dc 26\ubd84 49\ucd08 GMT-05:00
2000\ub144 11\uc6d4 13\uc77c (\uc6d4) \uc624\ud6c4 08\uc2dc26\ubd8449\ucd08
2000. 11. 13 \uc624\ud6c4 8\uc2dc 26\ubd84 49\ucd08 GMT-05:00
00. 11. 13 \uc624\ud6c4 8:26
--------Cut--------Here----------
b. in EUC-KR encoding
--------Cut--------Here----------
2000. 11. 13 ???? 8:26:49
2000?? 11?? 13?? ?????? ???? 8?? 26?? 49?? GMT-05:00
2000?? 11?? 13?? (??) ???? 08\uc2dc26\ubd8449??
2000. 11. 13 ???? 8?? 26?? 49?? GMT-05:00
00. 11. 13 ???? 8:26
--------Cut--------Here----------
(Review ID: 112207)
======================================================================