timezone-java
v1.1.0
Published
Converter between java.util.TimeZone strings and moment-timezone and vice versa
Downloads
989
Maintainers
Readme
timezone-java
Converter between java.util.TimeZone strings and moment-timezone and vice versa
API
toTimezone(timezone, [customTzMap])
convert java.util.TimeZone to moment-timezone
Parameters
| parameter | type | description |
| ----------------- | ------ | --------------------- |
| timezone
| string | java.util.TimeZone id |
| [customTzMap]
| object | custom timezone map |
Example
const {toTimezone} = require('timezone-java')
toTimezone('AET') // > 'Australia/Sydney'
// with custom map
const javaToMomentMap = { 'Etc/GMT+6': 'Asia/Tomsk' }
toTimezone('Etc/GMT+6', javaTzMap) // > 'Asia/Tomsk'
toJava(timezone, [customTzMap])
convert moment-timezone to java.util.TimeZone id
Parameters
| parameter | type | description |
| ----------------- | ------ | ------------------- |
| timezone
| string | moment-timezone |
| [customTzMap]
| object | custom timezone map |
Example
const {toJava} = require('timezone-java')
toJava('Asia/Tomsk') // > 'Etc/GMT+7'
// with custom map
const momentToJavaMap = { 'Asia/Tomsk': 'Etc/GMT+6' }
toJava('Asia/Tomsk', momentToJavaMap) // > 'Etc/GMT+6'
Installation
$ npm install timezone-java
Tests
$ npm test
LICENSE
Unlicense https://unlicense.org