@Override public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException { if (useTimestamp(provider)) { g.writeStartArray(); _serializeAsArrayContents(value, g, provider); g.writeEndArray(); return; } g.writeString((_formatter == null) ? value.toString() : value.format(_formatter)); }
@Override public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException { if (useTimestamp(provider)) { g.writeStartArray(); _serializeAsArrayContents(value, g, provider); g.writeEndArray(); return; } g.writeString((_formatter == null) ? value.toString() : value.format(_formatter)); }
@Override public void serializeWithType(YearMonth value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, typeSer.typeId(value, serializationShape(provider))); // need to write out to avoid double-writing array markers if (typeIdDef.valueShape == JsonToken.START_ARRAY) { _serializeAsArrayContents(value, g, provider); } else { g.writeString((_formatter == null) ? value.toString() : value.format(_formatter)); } typeSer.writeTypeSuffix(g, typeIdDef); }
@Override public void serializeWithType(YearMonth value, JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException { WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, typeSer.typeId(value, serializationShape(provider))); // need to write out to avoid double-writing array markers if (typeIdDef.valueShape == JsonToken.START_ARRAY) { _serializeAsArrayContents(value, g, provider); } else { g.writeString((_formatter == null) ? value.toString() : value.format(_formatter)); } typeSer.writeTypeSuffix(g, typeIdDef); }
@Override public String getAsString(FacesContext context, UIComponent component, Object value) { if (value == null) { return null; } if (value.toString().isEmpty()) { return ""; } YearMonth yearMonth = (YearMonth) value; return yearMonth.format(ofPattern("MM/yyyy")); } }
YearMonth thisMonth = YearMonth.now(); YearMonth lastMonth = thisMonth.minusMonths(1); YearMonth twoMonthsAgo = thisMonth.minusMonths(2); DateTimeFormatter monthYearFormatter = DateTimeFormatter.ofPattern("MMMM yyyy"); System.out.printf("Today: %s\n", thisMonth.format(monthYearFormatter)); System.out.printf("Last Month: %s\n", lastMonth.format(monthYearFormatter)); System.out.printf("Two Months Ago: %s\n", twoMonthsAgo.format(monthYearFormatter));
@ImmutablePreBuild private static void preBuild(Builder builder) { if (builder.label == null && builder.yearMonth != null) { builder.label = builder.yearMonth.format(FORMATTER); } }
/** * Summarizes this ETD future into string form. * * @return the summary description */ public String summaryDescription() { return variant.getCode() + expiry.format(YM_FORMAT); }
@Override public String getValueInsertTest() { return YearMonth.now().format(DateTimeFormatter.ofPattern(MMYYYY)); }
@Override protected String toStringPersistence(YearMonth originalValue) { return originalValue == null ? null : originalValue.format(formatter()); }
public static void main(String[] args) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM-yyyy", Locale.ENGLISH); YearMonth startDate = YearMonth.parse("Jan-2015", formatter); YearMonth endDate = YearMonth.parse("Apr-2015", formatter); while(startDate.isBefore(endDate)) { System.out.println(startDate.format(formatter)); startDate = startDate.plusMonths(1); } }
@Override public String getValueChangeTest() { return YearMonth.now().minusMonths(2).format(DateTimeFormatter.ofPattern(MMYYYY)); }
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu.MM"); YearMonth date = YearMonth.parse("2010.01", formatter); YearMonth end = YearMonth.parse("2010.05", formatter); while (!date.isAfter(end)) { System.out.println(date.format(formatter)); date = date.plusMonths(1); }
@Override public String getValueCloneTest() { return YearMonth.now().minusMonths(1).format(DateTimeFormatter.ofPattern(MMYYYY)); }
@Override public Object exec(List list) throws TemplateModelException { return getObject().format(createDateTimeFormatter(list, 0, "yyyy-MM")); } }
/** * Obtains an instance using the year-month. * * @param date the date associated with the parameter * @param yearMonth the year-month of the curve node * @return the parameter metadata based on the year-month */ public static YearMonthDateParameterMetadata of(LocalDate date, YearMonth yearMonth) { ArgChecker.notNull(date, "date"); ArgChecker.notNull(yearMonth, "yearMonth"); return new YearMonthDateParameterMetadata(date, yearMonth, yearMonth.format(FORMATTER)); }
@Override public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException { if (useTimestamp(provider)) { g.writeStartArray(); _serializeAsArrayContents(value, g, provider); g.writeEndArray(); return; } g.writeString((_formatter == null) ? value.toString() : value.format(_formatter)); }
@Override public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException { if (useTimestamp(provider)) { g.writeStartArray(); _serializeAsArrayContents(value, g, provider); g.writeEndArray(); return; } g.writeString((_formatter == null) ? value.toString() : value.format(_formatter)); }
@Override public void serialize(YearMonth value, JsonGenerator g, SerializerProvider provider) throws IOException { if (useTimestamp(provider)) { g.writeStartArray(); _serializeAsArrayContents(value, g, provider); g.writeEndArray(); return; } g.writeString((_formatter == null) ? value.toString() : value.format(_formatter)); }