글쓴이 :강신동 1998년 5월 20일 10:31:52
AIX용 JDK와 SUN의 윈도용 JDK간의
불일치와 버그가 있습니다.
시각에 관련된 버그입니다.
윈도95의 경우
D:\>java com.shindong.KST
1998.05.20 오전 10:12
1998.05.20
위와 같이 나오길 고대하면서 완성했습니다.
실제로 실행시키려고 IBM AIX에서 실행시켰더니 에러가
나서 찾아찾아 가보니
이런..
1998.5/20 10:11 오전
1998.5/20
요렇게 나오지 뭡니까?
String의 replace가 한번만 작동하는 군요 허거걱 --;
SUN JDK는 오전 10:11 로 나오고
AIX JDK는 10:11 오전 으로 나오는군요..
서로도운다는 SUN과 IBM의 JDK만해도 이렇게 버그가 심한데
HP의 JDK는 또 얼마나 더 심할까....
참고로 아래에 소스가 있습니다.
package com.shindong;
import java.util.Date;
import java.util.Locale;
import java.util.SimpleTimeZone;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class KST {
public static final int mph = 3600000;
public static final int POINT = 1;
public static String getDate(int i) { // DateFormat.LONG DateFormat.SHORT
SimpleDateFormat _sdf ;
_sdf = (SimpleDateFormat) DateFormat.getDateTimeInstance(
i, DateFormat.SHORT, Locale.KOREAN);
SimpleTimeZone _stz = new SimpleTimeZone(9* mph,"KST");
_sdf.setTimeZone(_stz);
long _t = System.currentTimeMillis();
String str = _sdf.format(new Date(_t));
return str; // 98-05-07 오전 11:57 first DateFormat.SHORT
} // 1998년 4월 18일 토 오후 4:51 first DateFormat.LONG
public static String getPoint()
{
String temp = null;
StringBuffer buffer = new StringBuffer();
temp = getDate(DateFormat.LONG);
buffer.append(temp.substring(0,4));
buffer.append(".");
temp = getDate(DateFormat.SHORT);
temp = temp.substring(3,temp.length());
buffer.append(temp.replace('-','.'));
return buffer.toString().trim(); // 1998.04.18 오후 5:06
}
public static String getPointDate()
{
String temp = getPoint();
return temp.substring(0,10); // 1998.04.18
}
public static void main(String[] args)
{
System.out.println(KST.getPoint());
System.out.println(KST.getPointDate());
return;
}
}