以下是一些代码,可以帮助您在解析时区之前进行设置:
// sdf contains a Calendar object with the default timezone.Date date = new Date();String formatPattern = ....;SimpleDateFormat sdf = new SimpleDateFormat(formatPattern);TimeZone T1;TimeZone T2;........// set the Calendar of sdf to timezone T1sdf.setTimeZone(T1);System.out.println(sdf.format(date));// set the Calendar of sdf to timezone T2sdf.setTimeZone(T2);System.out.println(sdf.format(date));// Use the 'calOfT2' instance-methods to get specific info// about the time-of-day for date 'date' in timezone T2.Calendar calOfT2 = sdf.getCalendar();
我发现的另一个类似问题也可能有所帮助:如何在Java中设置默认时区并控制日期在DB上的存储方式?
编辑:
这也是有关Java和日期的出色教程:http
:
//www.tutorialspoint.com/java/java_date_time.htm



