Simplified TimeZone

Discussion in 'Java' started by Lord Zoltar, Sep 23, 2008.

  1. Lord Zoltar

    Lord Zoltar Guest

    I am using a DateFormat with the following formate: "hh:mm aa (zz)
    MMMM dd, yyyy"
    The problem is that "(zz)" will return the current time zone as "EDT"
    or "EST". Is there another format that can be used to get to return
    "ET", and ignore the indicator of Standard/Daylight savings time?
    Lord Zoltar, Sep 23, 2008
    #1
    1. Advertising

  2. In article
    <>,
    Lord Zoltar <> wrote:

    > I am using a DateFormat with the following formate: "hh:mm aa (zz)
    > MMMM dd, yyyy"
    > The problem is that "(zz)" will return the current time zone as "EDT"
    > or "EST". Is there another format that can be used to get to return
    > "ET", and ignore the indicator of Standard/Daylight savings time?


    You might look at getDisplayName(boolean daylight, int style):

    <http://java.sun.com/javase/6/docs/api/java/util/TimeZone.html>

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 24, 2008
    #2
    1. Advertising

  3. Lord Zoltar

    Lord Zoltar Guest


    >
    > You might look at getDisplayName(boolean daylight, int style):
    >
    > <http://java.sun.com/javase/6/docs/api/java/util/TimeZone.html>


    getDisplayName(false, TimeZone.SHORT) returns "EST" to me and
    getDisplayName(true, TimeZone.SHORT) returns "EDT". What I really need
    to display is just "ET". I guess I could always just remove the middle
    character or remove any S/D, but I don't know if that would break any
    timezones besides Eastern Time.
    Lord Zoltar, Sep 24, 2008
    #3
  4. Lord Zoltar <> wrote:
    >> You might look at getDisplayName(boolean daylight, int style):
    >> <http://java.sun.com/javase/6/docs/api/java/util/TimeZone.html>

    > getDisplayName(false, TimeZone.SHORT) returns "EST" to me and
    > getDisplayName(true, TimeZone.SHORT) returns "EDT". What I really need
    > to display is just "ET". I guess I could always just remove the middle
    > character or remove any S/D, but I don't know if that would break any
    > timezones besides Eastern Time.


    Reading "ET", I'd think "what? extraterrestial time?" :)

    You can, of course, (if you're sure that the users of your
    program won't think that way), store the result of
    getDisplayName(...) in a variable (tz) and then do:
    if (tz.equals("EST") || tz.equals("EDT")) { tz="ET"; }

    I'd rather refrain from meddling with these internationally
    recognized abbreviations.
    Andreas Leitgeb, Sep 24, 2008
    #4
  5. Lord Zoltar

    Lew Guest

    On Sep 24, 10:36 am, Lord Zoltar <> wrote:
    > > You might look at getDisplayName(boolean daylight, int style):

    >
    > > <http://java.sun.com/javase/6/docs/api/java/util/TimeZone.html>

    >
    > getDisplayName(false, TimeZone.SHORT) returns "EST" to me and
    > getDisplayName(true, TimeZone.SHORT) returns "EDT". What I really need
    > to display is just "ET". I guess I could always just remove the middle
    > character or remove any S/D, but I don't know if that would break any
    > timezones besides Eastern Time.


    From the Javadocs:
    > For compatibility with JDK 1.1.x, some other three-letter time zone IDs
    > (such as "PST", "CTT", "AST") are also supported. However, their use is
    > deprecated because the same abbreviation is often used for multiple time
    > zones (for example, "CST" could be U.S. "Central Standard Time" and
    > "China Standard Time"), and the Java platform can then only recognize
    > one of them.
    Lew, Sep 24, 2008
    #5
  6. Lord Zoltar

    Lord Zoltar Guest


    >
    > Reading "ET", I'd think "what? extraterrestial time?" :)


    That's what I though too the first time, and that joke has been used
    at least 4 times since we first saw this requirement. I'm amazed it
    hasn't gotten old yet. ;)

    > You can, of course, (if you're sure that the users of your
    > program won't think that way),  store the result of
    > getDisplayName(...) in a variable (tz) and then do:
    > if (tz.equals("EST") || tz.equals("EDT")) { tz="ET"; }
    >
    > I'd rather refrain from meddling with these internationally
    > recognized abbreviations.


    Neither do I, but it looks like Java doesn't have a way to remove the
    Daylight savings/Standard indicator (D or S). I guess another option
    would be mapping tables... for every time zone. :(
    Lord Zoltar, Sep 24, 2008
    #6
  7. Lord Zoltar

    Lew Guest

    Andreas Leitgeb wrote:
    >> I'd rather refrain from meddling with these internationally
    >> recognized abbreviations.


    Are these abbreviations really "internationally recognized"? What is
    the standard? Can you point us to any references for more information
    on that?

    The quote from the Javadocs cited upthread,

    > ... other three-letter time zone IDs (such as "PST", "CTT", "AST")
    > are ... deprecated because the same abbreviation is often used for
    > multiple time zones


    seems to indicate otherwise. Looking up "standard" abbreviations I
    found a list at
    <http://www.timeanddate.com/library/abbreviations/timezones/>
    which only claims that the abbreviations they list are used "in some
    regions of the world". That site lists two expansions for EDT (UTC+11
    and UTC-4) three for EST (UTC+10, UTC+11 and UTC-5), and none for ET.

    --
    Lew
    Lew, Sep 24, 2008
    #7
  8. In article
    <>,
    Lord Zoltar <> wrote:

    > >
    > > Reading "ET", I'd think "what? extraterrestial time?" :)

    >
    > That's what I though too the first time, and that joke has been used
    > at least 4 times since we first saw this requirement. I'm amazed it
    > hasn't gotten old yet. ;)
    >
    > > You can, of course, (if you're sure that the users of your
    > > program won't think that way),  store the result of
    > > getDisplayName(...) in a variable (tz) and then do:
    > > if (tz.equals("EST") || tz.equals("EDT")) { tz="ET"; }
    > >
    > > I'd rather refrain from meddling with these internationally
    > > recognized abbreviations.

    >
    > Neither do I, but it looks like Java doesn't have a way to remove the
    > Daylight savings/Standard indicator (D or S). I guess another option
    > would be mapping tables... for every time zone. :(


    If you really have a compelling reason to do this anyway, the list isn't
    that long:

    $ javac Timezone.java ; java Timezone | sort | grep "[A-Z]D[A-Z]"
    CST6CDT: Central Standard Time
    EST5EDT: Eastern Standard Time
    MST7MDT: Mountain Standard Time
    PST8PDT: Pacific Standard Time
    SystemV/AST4ADT: Atlantic Standard Time
    SystemV/CST6CDT: Central Standard Time
    SystemV/EST5EDT: Eastern Standard Time
    SystemV/MST7MDT: Mountain Standard Time
    SystemV/PST8PDT: Pacific Standard Time
    SystemV/YST9YDT: Alaska Standard Time

    <code>
    import java.util.TimeZone;
    public class Timezone {
    public static void main(String[] args) {
    String[] tza = TimeZone.getAvailableIDs();
    for (int i = 0; i < tza.length; i++) {
    String name = TimeZone.getTimeZone(tza).getDisplayName();
    System.out.println(tza + ": " + name);
    }
    }
    }
    </code>

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 24, 2008
    #8
  9. In article <>,
    Lew <> wrote:

    > John B. Matthews wrote:
    > > If you really have a compelling reason to do this anyway, the list isn't
    > > that long:
    > >
    > > CST6CDT: Central Standard Time
    > > EST5EDT: Eastern Standard Time

    >
    > Too bad for the Australians.


    Good reasons not to monkey with other people's time zone abbreviations.

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 25, 2008
    #9
  10. Lew <> wrote:
    > Andreas Leitgeb wrote:
    >>> I'd rather refrain from meddling with these internationally
    >>> recognized abbreviations.

    > Are these abbreviations really "internationally recognized"? What is
    > the standard? Can you point us to any references for more information
    > on that?


    I didn't make a scientific study on it, but if it weren't,
    then a time-stamp like: Thu Sep 25 10:33:55 CEST 2008
    (from "date") wouldn't be all that useful.

    But then again, who knows, perhaps it indeed isn't...

    For me, two letter words in a timestamp (except for "ET")
    make me speculate about some other language's "am/pm" equivalent.
    Andreas Leitgeb, Sep 25, 2008
    #10
  11. In article <>,
    Andreas Leitgeb <> wrote:

    > Lew <> wrote:
    > > Andreas Leitgeb wrote:
    > >>> I'd rather refrain from meddling with these internationally
    > >>> recognized abbreviations.

    > >
    > > Are these abbreviations really "internationally recognized"? What is
    > > the standard? Can you point us to any references for more information
    > > on that?

    >
    > I didn't make a scientific study on it, but if it weren't,
    > then a time-stamp like: Thu Sep 25 10:33:55 CEST 2008
    > (from "date") wouldn't be all that useful.

    [...]

    Would it make sense to view these abbreviations as "locally recognized?"
    If I get up on Christmas morning in Sydney, Ohio, I interpret EST to
    mean Eastern Standard Time. My friend Phil in Sydney, Australia
    interprets EST as Eastern Summer Time:

    Dec 25, 2008 07:00:00 EST; UTC-0500; Sydney, Ohio
    Dec 25, 2008 23:00:00 EST; UTC+1100; Sydney, Australia

    [It'd be noon in Sydney, England, but I don't know anyone there.]

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 25, 2008
    #11
  12. On Sep 24, 10:26 pm, Lew <> wrote:
    > Andreas Leitgeb wrote:
    > >> I'd rather refrain from meddling with these internationally
    > >> recognized abbreviations.

    >
    > Are these abbreviations really "internationally recognized"?  What is
    > the standard?  Can you point us to any references for more information
    > on that?


    I believe that anything (unless specifically for the lower end of the
    US/CA market) which recognises time offset abbreviations will
    recognise 'UTC' and 'GMT'. Nothing else is safe over all systems and
    locations (except when built into code which is fully compiled before
    distribution). For example, the browser Opera does not recognise
    'EST', which is why some NASA Web event countdowns will be wrong in
    Opera except when/where local time is equivalent to US EST.

    I know of two meanings for EST, three for BST, three for IST.

    --
    (c) John Stockton, near London, UK. Posting with Google.
    Mail: J.R.""""""""@physics.org or (better) via Home Page at
    Web: <URL:http://www.merlyn.demon.co.uk/>
    FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
    Dr J R Stockton, Sep 25, 2008
    #12
  13. On Sep 25, 3:27 am, "John B. Matthews" <> wrote:

    > Good reasons not to monkey with other people's time zone abbreviations.


    Whatever Java documentation may call them, (US) EST EDT etc. are not
    time zones; though ET could be. They are time offset aindications.

    Time Zones are geographically fixed, except when changed by
    politicians; they do not change seasonally. See Wikipedia, or a
    respectable printed dictionary.

    --
    (c) John Stockton, near London, UK. Posting with Google.
    Mail: J.R.""""""""@physics.org or (better) via Home Page at
    Web: <URL:http://www.merlyn.demon.co.uk/>
    FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
    Dr J R Stockton, Sep 25, 2008
    #13
  14. Lord Zoltar

    Mark Space Guest

    John B. Matthews wrote:

    > Would it make sense to view these abbreviations as "locally recognized?"
    > If I get up on Christmas morning in Sydney, Ohio, I interpret EST to
    > mean Eastern Standard Time. My friend Phil in Sydney, Australia
    > interprets EST as Eastern Summer Time:


    Interesting. Does "Eastern" here mean eastern Australia or eastern US
    coast? Just curious....


    >
    > Dec 25, 2008 07:00:00 EST; UTC-0500; Sydney, Ohio
    > Dec 25, 2008 23:00:00 EST; UTC+1100; Sydney, Australia
    >
    > [It'd be noon in Sydney, England, but I don't know anyone there.]
    >
    Mark Space, Sep 25, 2008
    #14
  15. In article
    <>,
    Dr J R Stockton <> wrote:

    > On Sep 25, 3:27 am, "John B. Matthews" <> wrote:
    >
    > > Good reasons not to monkey with other people's time zone abbreviations.

    >
    > Whatever Java documentation may call them, (US) EST EDT etc. are not
    > time zones;


    Of course not. They are abbreviations used to signify the seasonally
    adjusted time in a geographic time zone. They are unambiguous only in
    (or near) the corresponding locale.

    > though ET could be.


    For what locale or zone(s)?

    > They are time offset aindications.


    As you suggested, UTC with a numeric offset has a much more widely
    understood meaning.

    [...]

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 25, 2008
    #15
  16. On Sep 25, 7:02 pm, "John B. Matthews" <> wrote:
    > In article
    > <>,
    >  Dr J R Stockton <> wrote:


    > > Whatever Java documentation may call them, (US) EST EDT etc. are not
    > > time zones;

    >
    > Of course not. They are abbreviations used to signify the seasonally
    > adjusted time in a geographic time zone. They are unambiguous only in
    > (or near) the corresponding locale.


    Verified by <http://www.time.gov/>.


    > > though ET could be.

    >
    > For what locale or zone(s)?


    It *could* be for the zone which in part alternately uses EST and
    EDT. Most zones can be identified by a single letter, as used by the
    US military; 25 letters, excluding J, for offsets -12 to +12 hours
    from GMT. That must cause problems when invading places whose offsets
    that does not cover.


    > > They are time offset aindications.

    >
    > As you suggested, UTC with a numeric offset has a much more widely
    > understood meaning.


    No. That's true, but it is not what I wrote.

    --
    (c) John Stockton, near London, UK. Posting with Google.
    Mail: J.R.""""""""@physics.org or (better) via Home Page at
    Web: <URL:http://www.merlyn.demon.co.uk/>
    FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
    Dr J R Stockton, Sep 25, 2008
    #16
  17. Dr J R Stockton <> wrote:
    > That must cause problems when invading places whose offsets
    > that does not cover.


    Especially when thusly missing that place's usual tea-time?
    Andreas Leitgeb, Sep 25, 2008
    #17
  18. In article <gbgcno$uas$>,
    Mark Space <> wrote:

    > John B. Matthews wrote:
    >
    > > Would it make sense to view these abbreviations as "locally recognized?"
    > > If I get up on Christmas morning in Sydney, Ohio, I interpret EST to
    > > mean Eastern Standard Time. My friend Phil in Sydney, Australia
    > > interprets EST as Eastern Summer Time:

    >
    > Interesting. Does "Eastern" here mean eastern Australia or eastern US
    > coast? Just curious....


    It depends. That's what I meant by "locally recognized." Phil and I both
    see "EST" from SimpleDateFormat("zzz"), but each would be wrong to
    interpret the other's abbreviation as if it were local. They are "locale
    specific," as described in the Javadocs.

    As I prepare to call Phil with Christmas greetings, I check the time in
    TimeZone.getTimeZone ("Australia/Sydney") and see that it's nearly
    midnight. I mention how we enjoyed the Vegemite he brought on his last
    visit; we hang up, because it's costing a fortune. I see his clock says
    EST, but I understand that's Eastern Summer Time down under.

    > > Dec 25, 2008 07:00:00 EST; UTC-0500; Sydney, Ohio
    > > Dec 25, 2008 23:00:00 EST; UTC+1100; Sydney, Australia

    [...]

    If I'm looking at a local event, the locale specific abbreviation makes
    sense; if I'm looking at world events, a SimpleDateFormat that includes
    "'UTC'Z'" is much easier to read.

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 25, 2008
    #18
  19. In article
    <>,
    Dr J R Stockton <> wrote:

    > On Sep 25, 7:02 pm, "John B. Matthews" <> wrote:
    > > In article
    > > <>,
    > >  Dr J R Stockton <> wrote:

    [...]
    > > > They are time offset aindications.

    > >
    > > As you suggested, UTC with a numeric offset has a much more widely
    > > understood meaning.

    >
    > No. That's true, but it is not what I wrote.

    [...]

    You wrote, "I believe that anything [...] which recognises time offset
    abbreviations will recognise 'UTC' and 'GMT'."

    Can you elaborate? I understand that UTC derives from international
    atomic time, while GMT relates to the Earth's rotation. I thought that
    Greenwich was on UTC:

    <http://www.parliament.the-stationery-office.co.uk/pa/ld199798/ldhansrd/v
    o970611/text/70611-10.htm>

    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
    John B. Matthews, Sep 25, 2008
    #19
  20. On Sep 25, 8:41 pm, "John B. Matthews" <> wrote:
    > In article
    > <>,


    > You wrote, "I believe that anything [...] which recognises time offset
    > abbreviations will recognise 'UTC' and 'GMT'."


    (by which I did not mean that "GMT -0500" would be acceptable)

    > Can you elaborate? I understand that UTC derives from international
    > atomic time, while GMT relates to the Earth's rotation. I thought that
    > Greenwich was on UTC:


    As far as I know, legal time in the UK is still GMT, because
    applicable legislation has not been changed to UTC. UK time signals,
    however, are UTC. Many EU countries are legally on UT. Astromomers
    will use whichever of the various types of time match the needs of
    their work.

    For details, search the Web - or try Wikipedia, or use links on my
    site.

    /Cognoscenti/ deprecate GMT nowadays (UT (2 letters) is the nearest
    approved notation) but /hoi polloi/ understand it.

    UTC is atomic time, all seconds identical, with a second added (or
    omitted) occasionally at the end of UTC June or December. It is kept
    within +-0.9 seconds of Earth Rotation Time. Few computers use it.
    In practice, GMT is time with 24*60*60 seconds per day, with the
    length of the second sometimes slightly adjusted so that the GMT and
    UTC days average the same.

    --
    (c) John Stockton, near London, UK. Posting with Google.
    Mail: J.R.""""""""@physics.org or (better) via Home Page at
    Web: <URL:http://www.merlyn.demon.co.uk/>
    FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
    Dr J R Stockton, Sep 26, 2008
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grey

    simplified chinese encoding

    Grey, Apr 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    494
  2. Guest
    Replies:
    0
    Views:
    398
    Guest
    Jun 24, 2005
  3. asaf
    Replies:
    3
    Views:
    6,136
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Sep 11, 2006
  4. axrock
    Replies:
    8
    Views:
    939
    Roedy Green
    Mar 25, 2009
  5. Ami
    Replies:
    5
    Views:
    267
Loading...

Share This Page