Package org.projectforge.xml.stream.converter

Examples of org.projectforge.xml.stream.converter.ISODateConverter


  public String exportAsXml(final GanttChart ganttChart, final boolean prettyFormat)
  {
    final Document document = DocumentHelper.createDocument();
    final XmlObjectWriter writer = getXmlGanttObjectWriter();
    final XmlRegistry xmlRegistry = new XmlRegistry();
    xmlRegistry.registerConverter(Date.class, new ISODateConverter());
    writer.setXmlRegistry(xmlRegistry);
    final MyRootElement root = new MyRootElement();
    root.ganttChart = ganttChart;
    root.setCreated().setTimeZone(PFUserContext.getTimeZone()).setVersion("1.0");
    final Element element = writer.write(document, root);
View Full Code Here


    final DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.AUGUST, 30, 9, 18, 57);
    root.setCreated(dh.getDate());
    final XmlObjectWriter writer = new XmlObjectWriter();
    final XmlRegistry xmlRegistry = new XmlRegistry();
    xmlRegistry.registerConverter(Date.class, new ISODateConverter());
    writer.setXmlRegistry(xmlRegistry);
    root.setTimeZone(DateHelper.EUROPE_BERLIN);
    final String xml = writer.writeToXml(root);
    assertEquals(
        "<ProjectForge timeZone=\"Europe/Berlin\" created=\"2010-08-30 09:18:57\"><testObject s1=\"hurzel\" d1=\"0.0\" i1=\"0\"/></ProjectForge>",
View Full Code Here

  @Test
  public void testIsoDateConverter()
  {
    final DateConverter dateConverter = new DateConverter();
    final ISODateConverter isoDateConverter = new ISODateConverter();
    final PFUserDO cetUser = new PFUserDO();
    cetUser.setTimeZone(DateHelper.EUROPE_BERLIN);
    PFUserContext.setUser(cetUser); // login CET user.
    DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.AUGUST, 29, 23, 8, 17, 123);
    assertEquals("1283116097123", dateConverter.toString(dh.getDate()));
    assertEquals("2010-08-29 23:08:17.123", isoDateConverter.toString(dh.getDate()));
    assertEquals("2010-08-29 23:08:17", isoDateConverter.toString(dh.setMilliSecond(0).getDate()));
    assertEquals("2010-08-29 23:08", isoDateConverter.toString(dh.setSecond(0).getDate()));
    assertEquals("2010-08-29 23:00", isoDateConverter.toString(dh.setMinute(0).getDate()));
    assertEquals("2010-08-29", isoDateConverter.toString(dh.setHourOfDay(0).getDate()));
    final PFUserDO utcUser = new PFUserDO();
    utcUser.setTimeZone(DateHelper.UTC);
    PFUserContext.setUser(utcUser); // login UTC user.
    dh = new DateHolder(DateHelper.UTC);
    dh.setDate(2010, Calendar.AUGUST, 29, 23, 8, 17, 123);
    assertEquals("2010-08-29 23:08:17.123", isoDateConverter.toString(dh.getDate()));
  }
View Full Code Here

    final DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.AUGUST, 29, 23, 8, 17, 123);
    obj.date = dh.getDate();
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"1283116097123\"/>", writer.writeToXml(obj));
    final XmlRegistry reg = new XmlRegistry();
    reg.registerConverter(Date.class, new ISODateConverter());
    writer.setXmlRegistry(reg);
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08:17.123\"/>", writer.writeToXml(obj));
    obj.date = dh.setMilliSecond(0).getDate();
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08:17\"/>", writer.writeToXml(obj));
    obj.date = dh.setSecond(0).getDate();
View Full Code Here

TOP

Related Classes of org.projectforge.xml.stream.converter.ISODateConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.