《Java编程技巧1001条》第373条: 了解不同的日期标准,
2017-12-20 15:08
537 查看
《Java编程技巧1001条》第9章 Java日期函数第373条 了解不同的日期标准
373 Understanding Different Date Standards
373 弄清不同的日期标准
The basis for standard time throughout the world is the meridian at Greenwich, England. You can specify the time for any location in the world in terms of the number of hours from Greenwich Mean Time, or simply GMT. Java uses midnight GMT, January 1st, 1970 for its epoch date. Java provides methods you can use to express the time based on two time locations: the time at Greenwich and your local time. Of course, the classes determine the time based on your computers clock and time-zone settings. Thus, you must make sure that both your systems time and time-zone settings are correct. When you need to express the time and date in terms of GMT, you can use the Date class toGMTString method. If you need the time expressed in the local time, use Date class toLocaleString method. The Date class getTimezoneOffset method determines the local time-zone offset, which is the number of minutes your program must add to Greenwich Mean Time to give the local time zone. This value includes the correction,if necessary, for daylight savings time.全世界的基本标准时间是英国格林威治子午线时间. 你可以用从格林威治平均时间(简记为GMT)开始算起的时数来表示世界上任何一个地区的时间. Java用1970年1月1号,12点(GMT)作为时代时间. Java为你提供了用两个时间位置来表示时间的方法,即格林威治时间和你的局部地区时间. 当然,实际的计算还决定于你的计算机的时钟和时间地区(time-zone)的设置. 因此,你必须保证你的系统时间和时间地区的设置都正确无误. 当你需要用GMT标准表示时间和日期时,你可使用Date类的toGMTString方法, 如果你想得到局部地区时间时,则你可使用Date类中的toLocaleString方法. Date类中的getTimezoneOffset方法则用来设置时间地区,它代表你所在的局部地区时间与GMT时间之间相差的分数,在你的程序中只要把这一分数加到GMT时间上,就可得到你所在的局部地区时间.
TIME \@ "MMMM d, yyyy"
November 24, 1996
相关文章推荐
- 《Java编程技巧1001条》第362条: 用日期类 建立你自己的 日期/时间
- 《Java编程技巧1001条》354条:了解伪随机与真随机
- 《Java编程技巧1001条》第604条:了解图像的观察器
- 《Java编程技巧1001条》360-373条:用日期函数获得当前日期
- 《Java编程技巧1001条》第379条: 初始化基本类型数组
- 《Java编程技巧1001条》第591-609条 播放声音剪辑
- 《Java编程技巧1001条》第375条: 使用DOS下的 TZ 环境变量,
- 《Java编程技巧1001条》第608条: 在装入图像时设置时间限制
- 《Java 编程技巧1001条》 第389条: 了解不平衡数组
- 《JAVA编程技巧1001条》第334条:数学函数 求绝对值.
- 《Java编程技巧1001条》357条:用高斯分布建立随机数
- 《Java 编程技巧1001条》 第382+283条: 了解数组的长度和引用
- 《Java 编程技巧1001条》 第395与396条 :了解和使用冒泡排序
- 《Java 编程技巧1001条》 第397+398条:了解和使用快速排序
- 《Java编程技巧1001条》第592条: 播放声音剪辑
- 《Java编程技巧1001条》第600条: 重用update方法来减少图像闪烁
- 《Java编程技巧1001条》 第605条: 检测图像装入过程
- 《JAVA编程技巧1001条》第335条:数学函数 SQRT.
- 《Java编程技巧1001条》 第345条:使用ceil方法
- 《JAVA编程技巧1001条》第337条:数学函数 SIN。