Class DateTagWriter


public class DateTagWriter extends SimpleTagWriter
XML tag writer for outputting Date objects. Additionally it allows to define the date format pattern.
  • Constructor Details

    • DateTagWriter

      public DateTagWriter(XMLTagWriter parent, String tagName)
      Creates a new optional date tag writer.
      Parameters:
      parent - the parent tag writer
      tagName - the tag name
    • DateTagWriter

      public DateTagWriter(XMLTagWriter parent, String tagName, boolean mandatory)
      Creates a new date tag writer.
      Parameters:
      parent - the parent tag writer
      tagName - the tag name
      mandatory - tells whether or not the tag writer requires a non-null value
  • Method Details

    • setDateFormat

      public void setDateFormat(String pattern) throws IllegalStateException
      Allows to define the date format by passing a SimpleDateFormat pattern to this tag.

      Be sure to call this before writing any object!

      Parameters:
      pattern - the pattern to use as date format
      Throws:
      IllegalStateException - when the tag writer has already begun to write any object
    • createDateFormat

      protected DateFormat createDateFormat()
      Creates the date format for this tag once.
    • getDateFormat

      protected final DateFormat getDateFormat()
    • writeContent

      protected void writeContent(org.znerd.xmlenc.XMLOutputter xmlOut, Object object) throws IOException
      Description copied from class: SimpleTagWriter
      Outputs the given objects by calling its Object.toString() method.
      Overrides:
      writeContent in class SimpleTagWriter
      Parameters:
      xmlOut - the XMLOutputter to write to
      object - the data object provided by the parent tag writer, may be null
      Throws:
      IOException