使用 Joda 时间将 UTC 偏移量转换为美国时区 [英] Convert UTC offset to USA time zone with Joda Time

查看:52
本文介绍了使用 Joda 时间将 UTC 偏移量转换为美国时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定 UTC 偏移量,即 -5,我可以使用 Joda 时间确定美国时区吗?Pacific、Mountain、Central、Easter 之一就足够了.我不能使用 Java 8.

Given a UTC offset, i.e. -5, can I determine the USA time zone using Joda Time? One of Pacific, Mountain, Central, Easter is sufficient. I can't use Java 8.

推荐答案

如果你只有有一个偏移量,那么不,你不能.例如,-5 可以是中部夏令时或东部标准时间.同样,偏移量 -7 可能是太平洋夏令时或山区标准时间.

If you only have an offset, then no, you can't. -5 could be Central Daylight Time or Eastern Standard Time, for example. Likewise an offset of -7 could be Pacific Daylight Time or Mountain Standard Time.

如果你有一个偏移量和一个有效的日期/时间,你可以做出一个很好的猜测——但前提是你假设美国的所有地方都切换到夏令时,并且所有地方都这样做时间 - 但并非完全如此.

If you have an offset and a date/time at which it was valid, you could make a pretty good guess - but only if you assume that everywhere in the US switches to daylight saving, and that everywhere does it at the same time - but that's not entirely the case.

这篇关于使用 Joda 时间将 UTC 偏移量转换为美国时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆