Class DateTagWriter


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

      • DateTagWriter

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

        public DateTagWriter​(XMLTagWriter parent,
                             java.lang.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 Detail

      • setDateFormat

        public void setDateFormat​(java.lang.String pattern)
                           throws java.lang.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:
        java.lang.IllegalStateException - when the tag writer has already begun to write any object
      • createDateFormat

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

        protected final java.text.DateFormat getDateFormat()
      • writeContent

        protected void writeContent​(org.znerd.xmlenc.XMLOutputter xmlOut,
                                    java.lang.Object object)
                             throws java.io.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:
        java.io.IOException