"IST"또는 "인도 표준시"등과 같이 주어진 시간대에서 현재 시간을 가져오고 싶습니다. 입력이 "인도 표준시"또는 "Coordinated Universal Time"인 경우 시간을 가져올 수 없습니다. 그것은 "IST"또는 "UTC"또는 "EST"등에 대해서만 작동합니다. 나는 Joda-Time 및 SimpleDateFormat을 시도했습니다.자바에서 주어진 시간대 이름에서 현재 시간을 얻는 방법?
SimpleDateFormat sd = new SimpleDateFormat(
"yyyy.MM.dd G 'at' HH:mm:ss z");
Date date = new Date();
sd.setTimeZone(TimeZone.getTimeZone("IST"));
System.out.println(sd.format(date));
DateTime now = new DateTime();
//DateTimeZone LDateTimeZone = DateTimeZone.forID("Asia/Kolkata");
DateTimeZone LDateTimeZone = DateTimeZone.forID("IST"); //deprecated
System.out.println("Joda-Time zone: " + now.toDateTime(LDateTimeZone));
두 입력을 모두 처리 할 수있는 방법이 있습니까?
전체 IANA TZ 데이터베이스 이름을 사용처럼 할 수 있다고 생각합니다. 약어는 고유하지 않으며 (인도/이스라엘/아일랜드?) 인간화 된 이름은 언어/지역에 따라 다릅니다. –