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:org.ohmage.streams.StreamPointBuilder.java

License:Apache License

/**
 * Sets the time for this point to now/*from  w ww  .  j a  v a  2s  .co m*/
 *
 * @return this
 */
public StreamPointBuilder now() {
    if (dateTimeFormatter == null)
        dateTimeFormatter = ISODateTimeFormat.dateTime().withOffsetParsed();
    mTimestamp = dateTimeFormatter.print(DateTime.now());
    return this;
}

From source file:org.ojbc.bundles.adapters.staticmock.samplegen.IncidentSampleGenerator.java

License:RPL License

private void addMessageMetadataElement(Element publishMessageElement) {
    Element messageMetadataElement = appendElement(publishMessageElement, OjbcNamespaceContext.NS_LEXS,
            "PDMessageMetadata");
    Element e = appendElement(messageMetadataElement, OjbcNamespaceContext.NS_LEXS, "LEXSVersion");
    e.setTextContent("3.1.4");
    e = appendElement(messageMetadataElement, OjbcNamespaceContext.NS_LEXS, "MessageDateTime");
    e.setTextContent(ISODateTimeFormat.dateTime().print(new DateTime()));
    e = appendElement(messageMetadataElement, OjbcNamespaceContext.NS_LEXS, "MessageSequenceNumber");
    e.setTextContent("1");
    e = appendElement(messageMetadataElement, OjbcNamespaceContext.NS_LEXS, "DataSensitivity");
    e.setTextContent("SBU");
}

From source file:org.ojbc.util.xml.XmlUtils.java

License:RPL License

public static final DateTime parseXmlDateTime(String dateTime) {
    if (dateTime == null || dateTime.trim().equals("")) {
        return null;
    }//from w w  w  . j a  va  2  s .  c  o m
    DateTimeParser[] parsers = new DateTimeParser[] {
            DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").getParser(),
            ISODateTimeFormat.dateTimeNoMillis().withOffsetParsed().getParser(),
            DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").getParser(),
            ISODateTimeFormat.dateTime().withOffsetParsed().getParser(), };
    DateTimeFormatterBuilder dateTimeFormatterBuilder = new DateTimeFormatterBuilder();
    dateTimeFormatterBuilder.append(null, parsers);
    return dateTimeFormatterBuilder.toFormatter().parseDateTime(dateTime);
}

From source file:org.ojbc.web.portal.controllers.PortalController.java

License:RPL License

UserLogonInfo getUserLogonInfo(Element assertionElement) {

    UserLogonInfo userLogonInfo = new UserLogonInfo();

    if (assertionElement == null) {
        log.warn("assertionElement was null, returning empty UserLogonInfo");
        return userLogonInfo;
    }//from  www .  j  av a 2s.c  o  m

    try {

        debugPrintAssertion(assertionElement);

        String instantString = (String) xPath.evaluate("/saml2:Assertion/saml2:AuthnStatement/@AuthnInstant",
                assertionElement, XPathConstants.STRING);
        DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
        DateTime authnInstant = fmt.parseDateTime(instantString);
        int minutesOnline = Minutes.minutesBetween(authnInstant, new DateTime()).getMinutes();
        int hoursOnline = (int) minutesOnline / 60;
        minutesOnline = minutesOnline % 60;
        userLogonInfo.timeOnlineString = String.valueOf(hoursOnline) + ":" + (minutesOnline < 10 ? "0" : "")
                + String.valueOf(minutesOnline);

        String userLastName = (String) xPath.evaluate(
                "/saml2:Assertion/saml2:AttributeStatement[1]/saml2:Attribute[@Name='gfipm:2.0:user:SurName']/saml2:AttributeValue/text()",
                assertionElement, XPathConstants.STRING);
        String userFirstName = (String) xPath.evaluate(
                "/saml2:Assertion/saml2:AttributeStatement[1]/saml2:Attribute[@Name='gfipm:2.0:user:GivenName']/saml2:AttributeValue/text()",
                assertionElement, XPathConstants.STRING);
        String userAgency = (String) xPath.evaluate(
                "/saml2:Assertion/saml2:AttributeStatement[1]/saml2:Attribute[@Name='gfipm:2.0:user:EmployerName']/saml2:AttributeValue/text()",
                assertionElement, XPathConstants.STRING);

        String sEmail = (String) xPath.evaluate(
                "/saml2:Assertion/saml2:AttributeStatement[1]/saml2:Attribute[@Name='gfipm:2.0:user:EmailAddressText']/saml2:AttributeValue/text()",
                assertionElement, XPathConstants.STRING);

        userLogonInfo.userNameString = (userFirstName == null ? "" : userFirstName) + " "
                + (userLastName == null ? "" : userLastName) + " / " + (userAgency == null ? "" : userAgency);
        userLogonInfo.emailAddress = sEmail;

    } catch (Exception e) {
        e.printStackTrace();
    }
    return userLogonInfo;
}

From source file:org.onebusaway.admin.search.impl.TimeWindowFilter.java

License:Apache License

private BigDecimal getTimeDifference(String timeReported) {
    DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
    DateTime lastReportedTime = formatter.parseDateTime(timeReported);
    DateTime now = new DateTime();
    int seconds = Seconds.secondsBetween(lastReportedTime, now).getSeconds();
    BigDecimal difference = new BigDecimal(seconds);
    return difference;
}

From source file:org.onebusaway.nyc.report.model.CcAndInferredLocationRecord.java

License:Apache License

private String toISODate(Date date) {
    if (date != null) {
        return ISODateTimeFormat.dateTime().print(new DateTime(date));
    }/*from ww w .  j  ava  2 s .com*/
    return null;
}

From source file:org.opencastproject.util.jaxb.UtcTimestampAdapter.java

License:Educational Community License

@Override
public String marshal(Date date) throws Exception {
    return ISODateTimeFormat.dateTime().withZoneUTC().print(new DateTime(date.getTime()));
}

From source file:org.openinfinity.core.aspect.AuditTrailAspect.java

License:Apache License

private void writeTimestampToAuditTrailIfEnabled(ArgumentBuilder builder, AuditTrail auditTrail) {
    if (auditTrail.isTimeStampEnabled()) {
        DateTime dateTime = new DateTime();
        DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
        String timeStamp = fmt.print(dateTime);
        builder.append("Timestamp: ").append("[").append(timeStamp).append("] ");
    }/*from  ww  w .ja  v  a 2 s .  c  o m*/
}

From source file:org.openiot.gsn.http.rest.RemoteWrapperParamParser.java

License:Open Source License

public String getStartTimeInString(long time) {
    return ISODateTimeFormat.dateTime().print(time);
}

From source file:org.openiot.gsn.utils.Helpers.java

License:Open Source License

public static long convertTimeFromIsoToLong(String time) throws Exception {
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    return fmt.parseDateTime(time).getMillis();
}