Format a time zone offset

70 views Asked by At

If I have a TimeZone, the string property currently produces the time zone in ISO-8601 format.

import ceylon.time.timezone {
    OffsetTimeZone
}

shared void run() {
    value timezone = OffsetTimeZone(27000000);
    print(timezone.string); // +07:30
}

Is there a way to get it in other formats, specifically without the colon (e.g. +0730)? (I mean, other than dropping the fourth character.) The ceylon.time.timezone.timeZone.parse function accepts offsets in this format, but I cannot figure out how to get them back.

1

There are 1 answers

2
Roland Tepp On

There’s more detailed formatting support in ceylon.locale module. See Formats type documentation.

Well, to be completely honest, it doesn’t give you a detailed formatting options that one might be used to when formatting dates in Java. You have basically just choices of short, medium and long date format and not much more.