java对世界各个时区(TimeZone)的通用转换处理方法(国外英文资料)
java对世界各个时区(TimeZone)的通用转换处理方法
Java has a general conversion approach to the world's time zone (TimeZone).
In the process of developing international software projects, there are sometimes more specific requirements. For example: for example, you do is a shopping site (assuming the server in Shanghai, China), when customers shopping on your web site order up and down all over the world, often want to see the customer location order of time, say I'm a New York man, I in your web site and single, you give me to see a Shanghai order time, will feel very strange. As is known to all, New York time relative to Shanghai is about 13 hours later, if let the customer see the local time zone time, will be more in line with the customer's concept of time, make customer understand more convenient.
In fact, has long been considered the world's time zones in Java (TimeZone) this problem, and presents a more reasonable solution, can be convenient to carry on the conversion of the world's time zones, will a time zones into another time zone. Take a look at the actual example below (the main () method running the example).
In terms of how you know your customer's time zone, you can calculate your time zone based on the client's IP or the country that the user registers.
Java code 01. / *
* Created on 2005-6-10
03. * the Author Stephen
* Email zhoujianqiang AT gmail DOT com
* CopyRight (C) 2005-2008, All rights reserved.
6. * /
7. Package com. Soft4j. The utility;
The euro.
09. Import Java. Text. A ParseException;
10. The import of Java. Text. SimpleDateFormat;
11. The import of Java. Util. Date;
12. The import of Java. Util. GregorianCalendar;
13. The import of Java. Util. TimeZone.
14. The import of Java. Util. Vector;
15.
16.
17.
/ * * 18.
* some common tools that are related to date and time.
* < p >
The common format for the date (time) is: < br >
* yyyy-mm-dd: MM: ss < br >
23. *
* @author Stephen
* @version 1.0.0
26. * /
Public final class DateTool {
28.
/ * * *
The date (time)