您尚未显示实际 使用 的位置
SimpleDateFormat。下面是其中短但完整的例子 确实 显示IST:
import java.text.*;import java.util.*;class Test { public static void main(String[] args) { SimpleDateFormat sd = new SimpleDateFormat( "yyyy.MM.dd G 'at' HH:mm:ss z"); Date date = new Date(); // TODO: Avoid using the abbreviations when fetching time zones. // Use the full Olson zone ID instead. sd.setTimeZone(TimeZone.getTimeZone("IST")); System.out.println(sd.format(date)); }}我的机器上的输出:
2012.05.23 AD at 11:18:08 IST
请注意,如果
TimeZone.getDefault()未显示“ IST”,则问题可能是:
- 系统实际上无法识别您的系统时区
- 您的Java安装没有有关i18n的完整时区信息
您正在使用哪个Java版本以及在哪个平台上使用?



