dashman
dashman

Reputation: 3018

When the app starts - how is the default timezone set? (Nativescript)

When the app starts - how is the default JVM timezone set?

I assume it get's the device's timezone (where ever they might be) - and that's what's returned by TimeZone.getDefault()

I'm not getting that behavior on Android simulator - I went into phone Settings for Date/time and explicitly set it to mine local.

It's off by 1 hr - almost as it doesn't know about daylight savings.

Upvotes: 0

Views: 453

Answers (1)

Sergey Mell
Sergey Mell

Reputation: 8040

I'm using the next function which allows me to get the device timezone.

import { isIOS } from '@nativescript/core';

export function getTimeZone(): string {
    if (isIOS) {
        return NSTimeZone.localTimeZone.name;
    } else {
        return java.util.TimeZone.getDefault().getID();
    }
}

Upvotes: 2

Related Questions