private static void appendEra(StringBuilder sb, LocalDate localDate) { if (localDate.get(ChronoField.ERA) == IsoEra.BCE.getValue()) { sb.append(" BC"); } } //JCP! endif
/** * Gets the list of eras for the chronology. * <p> * The list of eras is shared with {@link IsoEra}. * * @return the list of eras for the chronology, may be immutable, not null */ @Override public List<Era> eras() { return Arrays.<Era>asList(IsoEra.values()); }
@Override public String[] eras( String calendarType, Locale locale, TextWidth textWidth ) { TextStyle style = getStyle(textWidth, OutputContext.FORMAT); String[] eras = new String[2]; int i = 0; for (IsoEra era : IsoEra.values()) { eras[i] = era.getDisplayName(style, locale); i++; } return eras; }
/** * Creates the chronology era object from the numeric value. * <p> * The list of eras is shared with {@link IsoEra}. * * @param eraValue the era value * @return the calendar system era, not null * @throws DateTimeException if unable to create the era */ @Override public IsoEra eraOf(int eraValue) { return IsoEra.of(eraValue); }
/** * Gets the numeric era {@code int} value. * <p> * The era BCE has the value 0, while the era CE has the value 1. * * @return the era value, from 0 (BCE) to 1 (CE) */ @Override public int getValue() { return ordinal(); }
/** * Gets the list of eras for the chronology. * <p> * The list of eras is shared with {@link IsoEra}. * * @return the list of eras for the chronology, may be immutable, not null */ @Override public List<Era> eras() { return Arrays.<Era>asList(IsoEra.values()); }
/** * Creates the chronology era object from the numeric value. * <p> * The list of eras is shared with {@link IsoEra}. * * @param eraValue the era value * @return the calendar system era, not null * @throws DateTimeException if unable to create the era */ @Override public IsoEra eraOf(int eraValue) { return IsoEra.of(eraValue); }
/** * Parse a string and return a LocalDateTime representing its value. * * @param s The ISO formated date string to parse. * @return null if s is null or a LocalDateTime of the parsed string s. * @throws SQLException if there is a problem parsing s. */ public LocalDateTime toLocalDateTime(String s) throws SQLException { if (s == null) { return null; } int slen = s.length(); // convert postgres's infinity values to internal infinity magic value if (slen == 8 && s.equals("infinity")) { return LocalDateTime.MAX; } if (slen == 9 && s.equals("-infinity")) { return LocalDateTime.MIN; } ParsedTimestamp ts = parseBackendTimestamp(s); // intentionally ignore time zone // 2004-10-19 10:23:54+03:00 is 2004-10-19 10:23:54 locally LocalDateTime result = LocalDateTime.of(ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second, ts.nanos); if (ts.era == GregorianCalendar.BC) { return result.with(ChronoField.ERA, IsoEra.BCE.getValue()); } else { return result; } } //JCP! endif
@Override public List<Era> eras() { return Arrays.<Era>asList(IsoEra.values()); }
@Override public IsoEra eraOf(int eraValue) { return IsoEra.of(eraValue); }
@Override public String format(Temporal temporal) { if (temporal.get(ChronoField.ERA) != IsoEra.CE.getValue()) { return FMT_ERA.format(temporal); } return FMT.format(temporal); }
@Override public String format(Temporal value) { if (value.get(ChronoField.ERA) != IsoEra.CE.getValue()) { return FMT_ERA.format(value); } return FMT.format(value); }
@Override public Temporal adjustInto(Temporal temporal) { return temporal.with(ERA, getValue()); }
@Override public long getLong(TemporalField field) { if (field == ERA) { return getValue(); } else if (field instanceof ChronoField) { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.getFrom(this); }