2008년 12월 2일 화요일

JAVA Calendar [TIME]

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class getTime {

private Calendar calendar;

public String gettime() {

currenttime();
DateFormat df = new SimpleDateFormat("yyMMdd-hhmmss");
String sysdate = df.format(calendar.getTime());
return sysdate;

}

public String gettime_textarea() {

currenttime();
DateFormat df = new SimpleDateFormat("[ yy-MM-dd hh:mm:ss ]");
String sysdate = df.format(calendar.getTime());
return sysdate;

}

public void currenttime() {

calendar = Calendar.getInstance();
TimeZone tz = TimeZone.getTimeZone("GMT+06:00");
calendar.setTimeZone(tz);
}

}

댓글 없음:

댓글 쓰기