|
1 | 1 | /* |
2 | 2 | * ----------------------------------------------------------------------- |
3 | | - * Copyright © 2013-2022 Meno Hochschild, <http://www.menodata.de/> |
| 3 | + * Copyright © 2013-2024 Meno Hochschild, <http://www.menodata.de/> |
4 | 4 | * ----------------------------------------------------------------------- |
5 | 5 | * This file (ChineseCalendar.java) is part of project Time4J. |
6 | 6 | * |
|
67 | 67 | * |
68 | 68 | * <p><strong>Introduction</strong></p> |
69 | 69 | * |
70 | | - * <p>It is a lunisolar calendar which defines years consisting of 12 or 13 months. See also |
| 70 | + * <p>It is a lunisolar calendar which defines years consisting of 12 or 13 months. Modern China now uses |
| 71 | + * the gregorian calendar and uses this calendar mainly for determining the dates some festivals and the |
| 72 | + * actual cyclic year and zodiac. See also |
71 | 73 | * <a href="https://en.wikipedia.org/wiki/Chinese_calendar">Wikipedia</a>. </p> |
72 | 74 | * |
73 | 75 | * <p><strong>Following elements which are declared as constants are registered by this class</strong></p> |
|
135 | 137 | * formatter.format(chineseDate), |
136 | 138 | * is("Sat, 16. Eleventh Month 2018(wù-xū) dōngzhì")); |
137 | 139 | * </pre> |
| 140 | + * |
| 141 | + * <p>Printing gregorian dates together with Chinese cyclic year and zodiac: </p> |
| 142 | + * |
| 143 | + * <pre> |
| 144 | + * ChronoPrinter<PlainDate> yearPrinter = // for display of cyclic year |
| 145 | + * (PlainDate gregorianDate, StringBuilder buffer, AttributeQuery attributes) -> { |
| 146 | + * buffer.append( |
| 147 | + * gregorianDate.transform(ChineseCalendar.axis()).getYear().getDisplayName(Locale.TRADITIONAL_CHINESE)); |
| 148 | + * return Collections.emptySet(); |
| 149 | + * }; |
| 150 | + * |
| 151 | + * ChronoPrinter<PlainDate> zodiacPrinter = |
| 152 | + * (PlainDate gregorianDate, StringBuilder buffer, AttributeQuery attributes) -> { |
| 153 | + * buffer.append(gregorianDate.transform(ChineseCalendar.axis()).getYear().getZodiac(Locale.TRADITIONAL_CHINESE)); |
| 154 | + * return Collections.emptySet(); |
| 155 | + * }; |
| 156 | + * |
| 157 | + * ChronoFormatter<PlainDate> gf = ChronoFormatter.setUp(PlainDate.axis(), Locale.TRADITIONAL_CHINESE) |
| 158 | + * .addPattern("y(", PatternType.CLDR) |
| 159 | + * .addCustomized(PlainDate.COMPONENT, yearPrinter, ChronoParser.unsupported()) |
| 160 | + * //.startSection(Attributes.NUMBER_SYSTEM, NumberSystem.CHINESE_MANDARIN) // month and day in Chinese? |
| 161 | + * .addPattern(")年M月d日(", PatternType.CLDR) |
| 162 | + * //.endSection() |
| 163 | + * .addCustomized(PlainDate.COMPONENT, zodiacPrinter, ChronoParser.unsupported()) |
| 164 | + * .addLiteral(')') |
| 165 | + * .build(); |
| 166 | + * |
| 167 | + * String s = gf.print(PlainDate.of(2023, 11, 5)); |
| 168 | + * System.out.println(s); // 2023(癸卯)年11月5日(兔) |
| 169 | + * </pre> |
138 | 170 | * |
139 | 171 | * <p>Leap months can be formatted in various ways. Following example shows how to customize numerical printing |
140 | 172 | * when a non-Chinese language is used: </p> |
|
171 | 203 | * <p><strong>Einleitung</strong></p> |
172 | 204 | * |
173 | 205 | * <p>Es handelt sich um einen lunisolaren Kalender, dessen Jahre aus 12 oder 13 Monaten bestehen. |
174 | | - * Siehe auch <a href="https://en.wikipedia.org/wiki/Chinese_calendar">Wikipedia</a>. </p> |
| 206 | + * Das moderne China verwendet den gregorianischen Kalender und braucht diesen alten Bauernkalender |
| 207 | + * im wesentlichen zur zeitlichen Bestimmung einiger chinesischer Feste und des chinesischen |
| 208 | + * zyklischen Jahrs und Tierkreiszeichens (Zodiak). Siehe auch |
| 209 | + * <a href="https://en.wikipedia.org/wiki/Chinese_calendar">Wikipedia</a>. </p> |
175 | 210 | * |
176 | 211 | * <p><strong>Registriert sind folgende als Konstanten deklarierte Elemente</strong></p> |
177 | 212 | * |
|
241 | 276 | * is("Sat, 16. Eleventh Month 2018(wù-xū) dōngzhì")); |
242 | 277 | * </pre> |
243 | 278 | * |
| 279 | + * <p>Darstellung eines gregorianischen Datums zusammen mit dem chinesischen |
| 280 | + * zyklischen Jahr und Tierkreiszeichen (Zodiak): </p> |
| 281 | + * |
| 282 | + * <pre> |
| 283 | + * ChronoPrinter<PlainDate> yearPrinter = // zur Anzeige des zyklischen Jahres |
| 284 | + * (PlainDate gregorianDate, StringBuilder buffer, AttributeQuery attributes) -> { |
| 285 | + * buffer.append( |
| 286 | + * gregorianDate.transform(ChineseCalendar.axis()).getYear().getDisplayName(Locale.TRADITIONAL_CHINESE)); |
| 287 | + * return Collections.emptySet(); |
| 288 | + * }; |
| 289 | + * |
| 290 | + * ChronoPrinter<PlainDate> zodiacPrinter = // Tierkreiszeichen |
| 291 | + * (PlainDate gregorianDate, StringBuilder buffer, AttributeQuery attributes) -> { |
| 292 | + * buffer.append(gregorianDate.transform(ChineseCalendar.axis()).getYear().getZodiac(Locale.TRADITIONAL_CHINESE)); |
| 293 | + * return Collections.emptySet(); |
| 294 | + * }; |
| 295 | + * |
| 296 | + * ChronoFormatter<PlainDate> gf = ChronoFormatter.setUp(PlainDate.axis(), Locale.TRADITIONAL_CHINESE) |
| 297 | + * .addPattern("y(", PatternType.CLDR) |
| 298 | + * .addCustomized(PlainDate.COMPONENT, yearPrinter, ChronoParser.unsupported()) |
| 299 | + * //.startSection(Attributes.NUMBER_SYSTEM, NumberSystem.CHINESE_MANDARIN) // Monat und Tag auf Chinesisch? |
| 300 | + * .addPattern(")年M月d日(", PatternType.CLDR) |
| 301 | + * //.endSection() |
| 302 | + * .addCustomized(PlainDate.COMPONENT, zodiacPrinter, ChronoParser.unsupported()) |
| 303 | + * .addLiteral(')') |
| 304 | + * .build(); |
| 305 | + * |
| 306 | + * String s = gf.print(PlainDate.of(2023, 11, 5)); |
| 307 | + * System.out.println(s); // 2023(癸卯)年11月5日(兔) |
| 308 | + * </pre> |
| 309 | + * |
244 | 310 | * <p>Schaltmonate können verschieden formatiert werden. Das folgende Beispiel zeigt, wie man |
245 | 311 | * die numerische Formatierung im Fall einer nicht-chinesischen Sprache anpassen kann: </p> |
246 | 312 | * |
|
0 commit comments