안드로이드 개발 질문/답변
(글 수 45,052)
현재 timezone의 시간을 구하고 싶은데요.
아래와 같이 하였을때 현재 폰의 설정된 시간이 나옵니다.
US/Eastern의 시간이 왜 안나오는지 궁금합니다.
답변 부탁드립니다.
public String getTimeZoneTime(){
TimeZone tz=TimeZone.getTimeZone(US/Eastern);
String time;
Date date = new Date();
DateFormat df = new SimpleDateFormat("HH:mm:ss");
time=df.format(date);
Log.i(TAG,"TIME"+time);
return time;
}
}
아래와 같이 하였을때 현재 폰의 설정된 시간이 나옵니다.
US/Eastern의 시간이 왜 안나오는지 궁금합니다.
답변 부탁드립니다.
public String getTimeZoneTime(){
TimeZone tz=TimeZone.getTimeZone(US/Eastern);
String time;
Date date = new Date();
DateFormat df = new SimpleDateFormat("HH:mm:ss");
time=df.format(date);
Log.i(TAG,"TIME"+time);
return time;
}
}
2010.08.04 16:20:25
아래와 같이 calendar instance에서 얻어오니 제대로 동작하네요.public String getTimeZoneTime(){
String time;
Log.d(TAG,"TIMEZONE"+timezone);
Calendar cal=Calendar. getInstance();
cal.setTimeZone(TimeZone.getTimeZone(timezone));
time=""+cal.get(Calendar.HOUR_OF_DAY)+":"+cal.get(Calendar.MINUTE);
Log.d(TAG,"TIME"+cal.get(Calendar.HOUR_OF_DAY));
Log.d(TAG,"TIME"+cal.get(Calendar.MINUTE));
Log.d(TAG,time);
return time;



