Example usage for org.joda.time.format ISODateTimeFormat dateTime

List of usage examples for org.joda.time.format ISODateTimeFormat dateTime

Introduction

In this page you can find the example usage for org.joda.time.format ISODateTimeFormat dateTime.

Prototype

public static DateTimeFormatter dateTime() 

Source Link

Document

Returns a formatter that combines a full date and time, separated by a 'T' (yyyy-MM-dd'T'HH:mm:ss.SSSZZ).

Usage

From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeDialect.java

License:Open Source License

@Override
public Set<IProcessor> getProcessors() {
    Set<IProcessor> processors = new HashSet<IProcessor>();
    processors.add(new JodaTimeFormatProcessor("fullDate", DateTimeFormat.fullDate()));
    processors.add(new JodaTimeFormatProcessor("fullDateTime", DateTimeFormat.fullDateTime()));
    processors.add(new JodaTimeFormatProcessor("fullTime", DateTimeFormat.fullTime()));
    processors.add(new JodaTimeFormatProcessor("longDate", DateTimeFormat.longDate()));
    processors.add(new JodaTimeFormatProcessor("longDateTime", DateTimeFormat.longDateTime()));
    processors.add(new JodaTimeFormatProcessor("longTime", DateTimeFormat.longTime()));
    processors.add(new JodaTimeFormatProcessor("mediumDate", DateTimeFormat.mediumDate()));
    processors.add(new JodaTimeFormatProcessor("mediumDateTime", DateTimeFormat.mediumDateTime()));
    processors.add(new JodaTimeFormatProcessor("mediumTime", DateTimeFormat.mediumTime()));
    processors.add(new JodaTimeFormatProcessor("shortDate", DateTimeFormat.shortDate()));
    processors.add(new JodaTimeFormatProcessor("shortDateTime", DateTimeFormat.shortDateTime()));
    processors.add(new JodaTimeFormatProcessor("shortTime", DateTimeFormat.shortTime()));
    processors.add(new JodaTimeFormatProcessor("isoDateTime", ISODateTimeFormat.dateTime()));
    return processors;
}

From source file:ro.activemall.photoxserver.utils.thymeleafJoda.JodaTimeExpressionObject.java

License:Open Source License

/**
 * Formats the datetime with a JodaTime date time format
 *
 * @param dateTime//from   w  w  w  .  ja v  a2s. com
 *            The datetime
 * @return The formatted date
 */
public String isoDateTime(DateTime dateTime) {
    return format(dateTime, ISODateTimeFormat.dateTime());
}

From source file:se.nrm.bio.mediaserver.domain.MetadataHeader.java

private String setIsoDate() {
    DateTime dt = new DateTime();
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    String nowAsISO = fmt.print(dt);
    return nowAsISO;
}

From source file:se.softhouse.jargo.addons.DateTimeParser.java

License:Apache License

@Override
public String descriptionOfValidValues(Locale locale) {
    requireNonNull(locale);// w  ww  .  ja v a  2s.  c o m
    String unmistakableDate = new DateTime("2011-02-28", timeZone).toString(ISODateTimeFormat.dateTime());
    return "an ISO8601 date, such as " + unmistakableDate;
}

From source file:se.vgregion.pubsub.content.DateTimeUtils.java

License:Open Source License

/**
 * Formats a date time to ISO 8601 format
 * @param value/*  w  ww. j a  v a  2  s  .  c o m*/
 * @return
 */
public static String print(DateTime value) {
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
    return fmt.print(value);
}

From source file:se.vgregion.pubsub.loadtesting.LoadtestingServlet.java

License:Open Source License

public static String print(DateTime value) {
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
    return fmt.print(value);
}

From source file:services.api.ApiServiceImpl.java

License:Apache License

/**
 * Writes the project details to a .txt file
 *///from   w  w w .j a  v  a  2s. c o m
private static void writeProjectDetails(Project project, String mutantSequence, PrintWriter zipWriter)
        throws IOException {
    zipWriter.println("Mutant Analysis Generated on: " + ISODateTimeFormat.dateTime().print(new DateTime()));
    zipWriter.println("Project ID: " + project._id.toString());
    zipWriter.println("Project Name: " + project.getName());
    zipWriter.println("Project Description: " + project.getDescription());
    zipWriter.println("Species: " + project.getSpecies().getDisplayName());
    zipWriter.println("Wildtype Sequence: " + project.getWildSequence());
    zipWriter.println("Mutant Sequence: " + mutantSequence);
}

From source file:sg.edu.nus.cs2103t.omnitask.DateTimeConverter.java

License:Open Source License

/**
 * Gson invokes this call-back method during deserialization when it
 * encounters a field of the specified type.
 * <p>/*from  w  w  w.  j  av a 2 s  . co m*/
 *
 * In the implementation of this call-back method, you should consider
 * invoking
 * {@link JsonDeserializationContext#deserialize(JsonElement, Type)} method
 * to create objects for any non-trivial field of the returned object.
 * However, you should never invoke it on the the same type passing
 * {@code json} since that will cause an infinite loop (Gson will call your
 * call-back method again).
 *
 * @param json
 *            The Json data being deserialized
 * @param typeOfT
 *            The type of the Object to deserialize to
 * @return a deserialized object of the specified type typeOfT which is a
 *         subclass of {@code T}
 * @throws JsonParseException
 *             if json is not in the expected format of {@code typeOfT}
 */
// @Override
public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {
    final DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    return fmt.parseDateTime(json.getAsString());
}

From source file:sg.edu.nus.cs2103t.omnitask.DateTimeConverter.java

License:Open Source License

/**
 * Gson invokes this call-back method during serialization when it
 * encounters a field of the specified type.
 * <p>//from  w w  w . ja  va2 s  .c  om
 *
 * In the implementation of this call-back method, you should consider
 * invoking {@link JsonSerializationContext#serialize(Object, Type)} method
 * to create JsonElements for any non-trivial field of the {@code src}
 * object. However, you should never invoke it on the {@code src} object
 * itself since that will cause an infinite loop (Gson will call your
 * call-back method again).
 *
 * @param src
 *            the object that needs to be converted to Json.
 * @param typeOfSrc
 *            the actual type (fully genericized version) of the source
 *            object.
 * @return a JsonElement corresponding to the specified object.
 */
// @Override
public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) {
    final DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    return new JsonPrimitive(fmt.print(src));
}

From source file:test.unit.be.e_contract.dssp.client.SignResponseFactory.java

License:Open Source License

public static String createSignResponse(String responseId, String destination, String inResponseTo,
        String tokenId, byte[] tokenKey, String resultMajor, String resultMinor, String signerIdentity) {
    ObjectFactory dssObjectFactory = new ObjectFactory();
    be.e_contract.dssp.ws.jaxb.dss.async.ObjectFactory asyncObjectFactory = new be.e_contract.dssp.ws.jaxb.dss.async.ObjectFactory();
    be.e_contract.dssp.ws.jaxb.wsa.ObjectFactory wsaObjectFactory = new be.e_contract.dssp.ws.jaxb.wsa.ObjectFactory();
    be.e_contract.dssp.ws.jaxb.wsu.ObjectFactory wsuObjectFactory = new be.e_contract.dssp.ws.jaxb.wsu.ObjectFactory();
    be.e_contract.dssp.ws.jaxb.saml.protocol.ObjectFactory samlObjectFactory = new be.e_contract.dssp.ws.jaxb.saml.protocol.ObjectFactory();

    SignResponse signResponse = dssObjectFactory.createSignResponse();
    signResponse.setProfile(DigitalSignatureServiceConstants.PROFILE);
    Result result = dssObjectFactory.createResult();
    signResponse.setResult(result);//from   w  w  w  .  j a va  2  s . c om
    result.setResultMajor(resultMajor);
    if (null != resultMinor) {
        result.setResultMinor(resultMinor);
    }

    AnyType optionalOutputs = dssObjectFactory.createAnyType();
    signResponse.setOptionalOutputs(optionalOutputs);

    optionalOutputs.getAny().add(asyncObjectFactory.createResponseID(responseId));

    RelatesToType relatesTo = wsaObjectFactory.createRelatesToType();
    optionalOutputs.getAny().add(wsaObjectFactory.createRelatesTo(relatesTo));
    relatesTo.setValue(inResponseTo);

    TimestampType timestamp = wsuObjectFactory.createTimestampType();
    optionalOutputs.getAny().add(wsuObjectFactory.createTimestamp(timestamp));
    AttributedDateTime created = wsuObjectFactory.createAttributedDateTime();
    timestamp.setCreated(created);
    DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime()
            .withChronology(ISOChronology.getInstanceUTC());
    DateTime createdDateTime = new DateTime();
    created.setValue(dateTimeFormatter.print(createdDateTime));
    AttributedDateTime expires = wsuObjectFactory.createAttributedDateTime();
    timestamp.setExpires(expires);
    DateTime expiresDateTime = createdDateTime.plusMinutes(5);
    expires.setValue(dateTimeFormatter.print(expiresDateTime));

    AttributedURIType to = wsaObjectFactory.createAttributedURIType();
    optionalOutputs.getAny().add(wsaObjectFactory.createTo(to));
    to.setValue(destination);

    if (null != signerIdentity) {
        NameIdentifierType nameIdentifier = samlObjectFactory.createNameIdentifierType();
        nameIdentifier.setValue(signerIdentity);
        nameIdentifier.setFormat("urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName");
        optionalOutputs.getAny().add(dssObjectFactory.createSignerIdentity(nameIdentifier));
    }

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder;
    try {
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("DOM error: " + e.getMessage(), e);
    }
    Document document = documentBuilder.newDocument();

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class,
                be.e_contract.dssp.ws.jaxb.wsa.ObjectFactory.class,
                be.e_contract.dssp.ws.jaxb.wsu.ObjectFactory.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.marshal(signResponse, document);
    } catch (JAXBException ex) {
        throw new RuntimeException(ex);
    }
    try {
        sign(document, tokenId, tokenKey);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer;
    try {
        transformer = transformerFactory.newTransformer();
    } catch (TransformerConfigurationException e) {
        throw new RuntimeException("JAXP config error: " + e.getMessage(), e);
    }
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    try {
        transformer.transform(new DOMSource(document), new StreamResult(byteArrayOutputStream));
    } catch (TransformerException e) {
        throw new RuntimeException("JAXP error: " + e.getMessage(), e);
    }

    return Base64.encode(byteArrayOutputStream.toByteArray());
}