Convert Ruby to Java,Ruby時區字符串到java時區

2

The authoritative source for Rails time zone names to standard TZDB/IANA time zone identifiers is the TimeZone.MAPPING constant in the Rails source code here. If you are able to access this mapping in your Rails code, then you don't need to hardcode anything.

Rails時區名稱到標准TZDB / IANA時區標識符的權威來源是此處Rails源代碼中的TimeZone.MAPPING常量。如果您能夠在Rails代碼中訪問此映射,則無需對任何內容進行硬編碼。

If rather (as it appears in the question comments) that you need to do the translation in your Java code, then you'll have to parse this mapping from the Rails code into something usable in your Java code, and periodically check for changes. Thankfully, the Rails developers don't seem to change this list often.

如果您需要在Java代碼中進行轉換(因為它出現在問題注釋中),那么您必須將此映射從Rails代碼解析為Java代碼中可用的內容,並定期檢查更改。值得慶幸的是,Rails開發人員似乎並沒有經常更改此列表。

I don't know of a Java library that already does this for you, but .NET developers can take advantage of my TimeZoneConverter library, which imports this mapping. If you want to write your own code for this, feel free to translate my LoadRailsMapping function from C# to Java.

我不知道已經為你做過這個的Java庫,但是.NET開發人員可以利用我的TimeZoneConverter庫來導入這個映射。如果您想為此編寫自己的代碼,請隨意將我的LoadRailsMapping函數從C#轉換為Java。

See also my notes on Rails time zone names at the bottom of the timezone tag wiki.

另請參閱timezone標記wiki底部有關Rails時區名稱的說明。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值