Fields { public static TimeField createTimeField(OdfElement odfElement) { TimeField timeField = new TimeField(odfElement); timeField.setFixed(false); return timeField; } private  Fields(); static DateField createDateField(OdfElement odfElement); static DateField createFixedDateField(OdfElement odfElement); static TimeField createTimeField(OdfElement odfElement); static TimeField createFixedTimeField(OdfElement odfElement); static PageNumberField createPreviousPageNumberField(OdfElement odfElement); static PageNumberField createCurrentPageNumberField(OdfElement odfElement); static PageNumberField createNextPageNumberField(OdfElement odfElement); static PageCountField createPageCountField(OdfElement odfElement); static TitleField createTitleField(OdfElement odfElement); static SubjectField createSubjectField(OdfElement odfElement); static AuthorField createAuthorNameField(OdfElement odfElement); static AuthorField createAuthorInitialsField(OdfElement odfElement); static ChapterField createChapterField(OdfElement odfElement); static ReferenceField createReferenceField(OdfElement odfElement, String referenceName); static VariableField createSimpleVariableField(VariableContainer container, String name); static VariableField createUserVariableField(VariableContainer container, String name, String value); static ConditionField createConditionField(OdfElement odfElement, String condition, String trueText,
			String falseText); static ConditionField createHiddenTextField(OdfElement odfElement, String condition, String text);  }
@Test public void testAddTimeField() { try { TextDocument doc = TextDocument.newTextDocument(); TimeField timeField = Fields.createTimeField(doc.newParagraph("Time:")); Assert.assertNotNull(timeField); TextTimeElement timeEle = timeField.getOdfElement(); String oldContent = timeEle.getTextContent(); SimpleDateFormat oldFormat = new SimpleDateFormat("HH:mm:ss"); Date oldDate = oldFormat.parse(oldContent); String format = "HH:mm:ss a"; timeField.formatTime(format); String newContent = timeEle.getTextContent(); SimpleDateFormat newFormat = new SimpleDateFormat(format); Date newDate = newFormat.parse(newContent); Assert.assertEquals(oldDate.getTime(), newDate.getTime()); } catch (Exception e) { Logger.getLogger(FieldsTest.class.getName()).log(Level.SEVERE, null, e); Assert.fail(e.getMessage()); } }