다음 형식으로 Google API에서 오는 특정 날짜와 시간이 +10 : 00 GMT (호주 / 멜버른)입니다.
2015-05-12T14 : 00 : 00.000 + 10 : 00
이제 위의 시간을 기기의 현재 시간대에 따라 변환하고 싶습니다.
예를 들면 :-
+5 : 30 GMT (인도)의 위 시간은 2015-05-12 9:30:00 이어야합니다.
어떻게 할 수 있습니까?
내 아래 코드는 :-
SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sourceFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date parsed = null;
try {
parsed = sourceFormat.parse("2015-05-12 14:00:00");
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} // => Date is in UTC now
TimeZone tz = TimeZone.getTimeZone(TimeZone.getDefault().getID());
SimpleDateFormat destFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
destFormat.setTimeZone(tz);
String result = destFormat.format(parsed);
System.out.println(result);
하지만 결과는 2015-05-12 19:30 이네요.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다