[prev in list] [next in list] [prev in thread] [next in thread]
List: icu4j-discussion
Subject: Re: [ICU4J-discussion] Re: Japanese ERA in
From: Alan Liu <alansliu () yahoo ! com>
Date: 2001-12-12 0:19:13
[Download RAW message or body]
Hi Ira,
A few comments. First of all, the factory method does not yet return any traditional \
calendars. So getInstance(LOCALE) only returns a GregorianCalendar parameterized for \
that locale, in terms of the first day of the week and so on. In order to get a \
Japanese calendar, you need to instantiate one directly. In the future, you should \
be able to do something like this:
Calendar cal = Calendar.getInstance(Calendar.TRADITIONAL, Locale.Japan);
-or-
Calendar cal = Calendar.getInstance(Calendar.MODERN, Locale.Japan);
but this isn't implemented yet.
Second, JapaneseCalendar.HEISEI is a field value for the ERA field, not an field \
number. Because of the loose typing in Calendar, this kind of error is inevitable.
And finally, there are probably bugs in JapaneseCalendar -- this class is still under \
development. The following source is closer to what you want:
Calendar cal = new JapaneseCalendar(Locale.JAPAN);
for (int i = 1; i < 10; i++) {
cal.add(Calendar.ERA, -1);
System.out.println(cal.get(Calendar.ERA) + ":" +
cal.getTime());
}
but it still may not give you exactly the results you expect.
Please file bugs about all this (so it gets fixed).
Alan Liu
IBM
At 10:20 PM 12/2/2001 -0800, Ira Waxberg wrote:
> Nope, Hesei is a constant for the era starting in
> 1989. Nothing seems to change the ERA field; Example:
>
> import ibm.util.*;
> Calendar cal = new Calendar.getInstance();
> System.out.println(cal.get(JapaneseCalendar.ERA));
> calendar.set(JapaneseCalendar.ERA, JapaneseCalendar,
> TAISHO);
> System.out.println(cal.get(JapaneseCalendar.ERA));
>
> Ouput:
> 1
> 1
>
> Ira
>
> ---- Ira Waxberg <ira@waxberg.com> wrote:
> > My previous post was misleading. I am really trying
> > to get the Hesei field from the Japanese calendar.
> > When I try to get or set this field in
> > com.ibm.util.JapaneseCalendar, I get an
> > ArrayIndexOutOfBoundsException. I noticed that when
> I
> > called getInstance() on
> com.ibm.util.JapaneseCalendar
> > I got a GregorianCalendar returned as a
> > com.ibm.util.Calendar, so I see why this wouldn't
> > work. Anyone know what's going on here?
> >
> > Ira
> >
> > ------------- Original Post ----------------
> >
> > Changing the ERA field in the icu4j Calendar seems
> to
> > have no effect on the field value. Am I doing
> > something wrong here?
> >
> > com.ibm.util.Calendar cal =
> > com.ibm.util.Calendar.getInstance
> > (java.util.Locale.JAPAN);
> > for (int i = 1; i < 10; i++)
> > {
> > cal.add(com.ibm.util.Calendar.ERA, -1);
> > System.out.println(cal.get
> > (com.ibm.util.Calendar.ERA));
> > }
> >
> > Your help is appreciated,
> >
> >
> > ---------------
> > ira@waxberg.com
> >
> >
>
> ---------------
> ira@waxberg.com
> _______________________________________________
> ICU4J-discussion mailing list
> ICU4J-discussion@www-124.ibm.com
> http://www-124.ibm.com/developerworks/oss/mailman/listinfo/icu4j-discussion
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic