Re: [threeten-develop] Difficulty printing a Date in a custom Chronology
Status: Alpha
Brought to you by:
scolebourne
From: Stephen C. <sco...@jo...> - 2015-01-17 22:52:30
|
I haven't experimented with it, but in theory additional calendar resource data can be added. See http://docs.oracle.com/javase/8/docs/technotes/guides/intl/enhancements.8.html#api http://docs.oracle.com/javase/8/docs/api/java/util/spi/CalendarNameProvider.html You know as much as I do though... Stephen On 16 January 2015 at 10:49, Carlo Dapor <ca...@gm...> wrote: > Hello 3-teners > > > I developed a calendar which works with 13 months by 28 days; the > months are the same ones found in the Gregorian calendar. > Except for an extra month placed between June and July, called Sol. > > A simple code snippet to illustrate what I want to achieve: > > public class NotTestIfc { > public static void main(final String[] args) { > //Locale locale = Locale.forLanguageTag("en-US-u-ca-ifc"); > Locale locale = Locale.forLanguageTag("en-u-ca-ifc"); > System.out.println(locale.toString()); > //Locale.setDefault(locale); > > InternationalFixedDate date = InternationalFixedDate.of(2013, 13, 1); > //InternationalFixedDate date = InternationalFixedDate.of(2013, 12, 1); > System.out.println(date); > > Chronology chrono = Chronology.ofLocale(locale); > System.out.println(chrono); > > DateTimeFormatter formatter = > DateTimeFormatter > //.ofPattern("MMMM dd yyyy") > .ofLocalizedDate(FormatStyle.LONG) > .withLocale(locale) > .withChronology(chrono); > String s = formatter.format(date); > System.out.println(s); > String s2 = date.format(formatter); > > System.out.println(s2); > } > } > > The code should print "December 01 2013", but instead prints " 01 2013". > If the date was 2013, 12, 1, then December 01 2013 is printed, which > is incorrect. > > You need to clone https://github.com/catull/threeten-extra.git to see > InternationalFixedDate / InternationalFixedChronology etc. > > Providing my own sun.text.resources.en.FormatDate_en class as .. > > package sun.text.resources.en; > > import java.util.ListResourceBundle; > > public class FormatData_en extends ListResourceBundle { > @Override > protected Object[][] getContents() { > return new Object[][] { > { "NumberPatterns", > new String[] { > "#,##0.###;-#,##0.###", // decimal pattern > "\u00A4#,##0.00;-\u00A4#,##0.00", // > currency pattern > "#,##0%" // percent pattern > } > }, > { "DateTimePatternChars","GyMdkHmsSEDFwWahKzZ" }, > { "MonthNames", > new String[] { "January", "February", "March", > "April", "May", "June", "Sol", "July", "August", "September", > "October", "November", "December" } }, > { "MonthAbbreviations", > new String[] { "Jan", "Feb", "Mar", "Apr", > "May", "Jun", "Sol", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } > } > > }; > } > } > > > ... changes nothing as far as date printing is concerned. > > What am I missing ? > > > Regards, > -- > Carlo > > ------------------------------------------------------------------------------ > New Year. New Location. New Benefits. New Data Center in Ashburn, VA. > GigeNET is offering a free month of service with a new server in Ashburn. > Choose from 2 high performing configs, both with 100TB of bandwidth. > Higher redundancy.Lower latency.Increased capacity.Completely compliant. > http://p.sf.net/sfu/gigenet > _______________________________________________ > threeten-develop mailing list > thr...@li... > https://lists.sourceforge.net/lists/listinfo/threeten-develop |