785 * @param textLookup the map from the value to the text
786 * @return this, for chaining, not null
787 */
788 public DateTimeFormatterBuilder appendText(TemporalField field, Map<Long, String> textLookup) {
789 Objects.requireNonNull(field, "field");
790 Objects.requireNonNull(textLookup, "textLookup");
791 Map<Long, String> copy = new LinkedHashMap<>(textLookup);
792 Map<TextStyle, Map<Long, String>> map = Collections.singletonMap(TextStyle.FULL, copy);
793 final LocaleStore store = new LocaleStore(map);
794 DateTimeTextProvider provider = new DateTimeTextProvider() {
795 @Override
796 public String getText(Chronology chrono, TemporalField field,
797 long value, TextStyle style, Locale locale) {
798 return store.getText(value, style);
799 }
800 @Override
801 public String getText(TemporalField field, long value, TextStyle style, Locale locale) {
802 return store.getText(value, style);
803 }
804 @Override
805 public Iterator<Entry<String, Long>> getTextIterator(TemporalField field, TextStyle style, Locale locale) {
806 return store.getTextIterator(style);
807 }
808 };
809 appendInternal(new TextPrinterParser(field, TextStyle.FULL, provider));
810 return this;
811 }
812
813 //-----------------------------------------------------------------------
814 /**
815 * Appends an instant using ISO-8601 to the formatter, formatting fractional
816 * digits in groups of three.
817 * <p>
818 * Instants have a fixed output format.
819 * They are converted to a date-time with a zone-offset of UTC and formatted
820 * using the standard ISO-8601 format.
821 * With this method, formatting nano-of-second outputs zero, three, six
822 * or nine digits as necessary.
823 * The localized decimal style is not used.
824 * <p>
825 * The instant is obtained using {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS}
|
785 * @param textLookup the map from the value to the text
786 * @return this, for chaining, not null
787 */
788 public DateTimeFormatterBuilder appendText(TemporalField field, Map<Long, String> textLookup) {
789 Objects.requireNonNull(field, "field");
790 Objects.requireNonNull(textLookup, "textLookup");
791 Map<Long, String> copy = new LinkedHashMap<>(textLookup);
792 Map<TextStyle, Map<Long, String>> map = Collections.singletonMap(TextStyle.FULL, copy);
793 final LocaleStore store = new LocaleStore(map);
794 DateTimeTextProvider provider = new DateTimeTextProvider() {
795 @Override
796 public String getText(Chronology chrono, TemporalField field,
797 long value, TextStyle style, Locale locale) {
798 return store.getText(value, style);
799 }
800 @Override
801 public String getText(TemporalField field, long value, TextStyle style, Locale locale) {
802 return store.getText(value, style);
803 }
804 @Override
805 public Iterator<Entry<String, Long>> getTextIterator(Chronology chrono,
806 TemporalField field, TextStyle style, Locale locale) {
807 return store.getTextIterator(style);
808 }
809 @Override
810 public Iterator<Entry<String, Long>> getTextIterator(TemporalField field,
811 TextStyle style, Locale locale) {
812 return store.getTextIterator(style);
813 }
814 };
815 appendInternal(new TextPrinterParser(field, TextStyle.FULL, provider));
816 return this;
817 }
818
819 //-----------------------------------------------------------------------
820 /**
821 * Appends an instant using ISO-8601 to the formatter, formatting fractional
822 * digits in groups of three.
823 * <p>
824 * Instants have a fixed output format.
825 * They are converted to a date-time with a zone-offset of UTC and formatted
826 * using the standard ISO-8601 format.
827 * With this method, formatting nano-of-second outputs zero, three, six
828 * or nine digits as necessary.
829 * The localized decimal style is not used.
830 * <p>
831 * The instant is obtained using {@link ChronoField#INSTANT_SECONDS INSTANT_SECONDS}
|