DateTimeFormatRenderer class
Renders {@link Date} objects with a {@link DateTimeFormat}.
class DateTimeFormatRenderer extends AbstractRenderer<DateTime> { DateTimeFormat format; TimeZone timeZone; /** * Create an instance with the given format and time zone. */ DateTimeFormatRenderer([DateTimeFormat format = null, TimeZone timeZone = null]) { if (format == null) { this.format = DateTimeFormat.getPredefinedFormat(PredefinedFormat.DATE_SHORT); } else { this.format = format; } this.timeZone = timeZone; } String render(DateTime object) { if (object == null) { return ""; } return format.format(object, timeZone); } }
Extends
AbstractRenderer<DateTime> > DateTimeFormatRenderer
Constructors
new DateTimeFormatRenderer([DateTimeFormat format = null, TimeZone timeZone = null]) #
Create an instance with the given format and time zone.
DateTimeFormatRenderer([DateTimeFormat format = null, TimeZone timeZone = null]) { if (format == null) { this.format = DateTimeFormat.getPredefinedFormat(PredefinedFormat.DATE_SHORT); } else { this.format = format; } this.timeZone = timeZone; }
Methods
String render(DateTime object) #
void renderTo(T object, Appendable appendable) #
inherited from AbstractRenderer
Renders {@code object} as plain text, appended directly to {@code appendable}. Should never throw any exceptions except if {@code appendable} throws an {@code IOException}.
void renderTo(T object, Appendable appendable) { appendable.append(render(object)); }