这不是一个真正的答案,但它太大而无法发表评论。这就是我发现的。
我的测试看起来像这样
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
Calendar cl = Calendar.getInstance(tz);
System.out.println(tz.getDisplayName());
String dayname = cl.getDisplayName(Calendar.DAY_OF_WEEK,Calendar.SHORT,Locale.US);
String monthname = cl.getDisplayName(Calendar.MONTH,Calendar.SHORT,Locale.US);
int hour = cl.get(Calendar.HOUR);
int min = cl.get(Calendar.MINUTE);
int sec = cl.get(Calendar.SECOND);
int mill = cl.get(Calendar.MILLISECOND);
int year = cl.get(Calendar.YEAR);
System.out.println("Time = " + cl.getTime().toString());
System.out.println("Manually = " +
dayname + " " + monthname + " " +
hour + ":" + min +":" + sec + ":" + mill + " " +
cl.getTimeZone().getDisplayName(Locale.US) + " " + year);
这给出了输出
Pacific Standard Time
Time = Tue Nov 05 11:36:33 EST 2013
Manually = Tue Nov 8:36:33:238 Pacific Standard Time 2013
看着Calendar.getTime()
:
public final Date getTime() {
return new Date(getTimeInMillis());
}
随着弹跳球...
public long getTimeInMillis() {
if (!isTimeSet) {
updateTime();
}
return time;
}
private void updateTime() {
computeTime();
// The areFieldsSet and areAllFieldsSet values are no longer
// controlled here (as of 1.5).
isTimeSet = true;
}
但我没有来源,computTime()
所以这就是我停下来的地方。
加布里埃尔的回答有效,fwiw。