Example usage for org.joda.time DateTime toString

List of usage examples for org.joda.time DateTime toString

Introduction

In this page you can find the example usage for org.joda.time DateTime toString.

Prototype

@ToString
public String toString() 

Source Link

Document

Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ).

Usage

From source file:DateTimeTypeAdapter.java

License:Apache License

@Override
public void write(JsonWriter out, DateTime value) throws IOException {
    if (value == null) {
        out.nullValue();// ww w.  j  a  v a 2  s. c o  m
    } else {
        out.value(value.toString());
    }
}

From source file:annis.adapter.DateTimeAdapter.java

License:Apache License

@Override
public String marshal(DateTime v) throws Exception {
    return v.toString();
}

From source file:applango.common.services.DB.mongo.mongoDB.java

public static DBObject getRollupValue(DBCollection coll, String userId) {
    logger.info("Getting today's rollup record for user " + userId);
    DBCursor cursor;/*  ww w  .  j  a va 2s .  c  o  m*/
    int maxWait = 10;
    try {
        DateTime jsonToday = new DateTime();
        DateTime yesterday = new DateTime().minusDays(1);

        Date yesterdayDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse(yesterday.toString());
        BasicDBObject dateQueryObj = new BasicDBObject("beginDate", new BasicDBObject("$gt", yesterdayDate));
        dateQueryObj.append("userId", userId);
        dateQueryObj.append("customerId", "automationCustomer");
        dateQueryObj.append("appName", "salesforce");

        cursor = coll.find(dateQueryObj);

        while ((cursor.count() == 0) && maxWait > 0) {
            sleep(1000);
            maxWait--;
        }

    } catch (Exception ex) {
        cursor = null;
        logger.error(ex.getMessage());
    }
    return cursor.next();
}

From source file:azkaban.app.PropsUtils.java

License:Apache License

public static Props produceParentProperties(final ExecutableFlow flow) {
    Props parentProps = new Props();

    parentProps.put("azkaban.flow.id", flow.getId());
    parentProps.put("azkaban.flow.uuid", UUID.randomUUID().toString());

    DateTime loadTime = new DateTime();

    parentProps.put("azkaban.flow.start.timestamp", loadTime.toString());
    parentProps.put("azkaban.flow.start.year", loadTime.toString("yyyy"));
    parentProps.put("azkaban.flow.start.month", loadTime.toString("MM"));
    parentProps.put("azkaban.flow.start.day", loadTime.toString("dd"));
    parentProps.put("azkaban.flow.start.hour", loadTime.toString("HH"));
    parentProps.put("azkaban.flow.start.minute", loadTime.toString("mm"));
    parentProps.put("azkaban.flow.start.seconds", loadTime.toString("ss"));
    parentProps.put("azkaban.flow.start.milliseconds", loadTime.toString("SSS"));
    parentProps.put("azkaban.flow.start.timezone", loadTime.toString("ZZZZ"));
    return parentProps;
}

From source file:azkaban.app.Scheduler.java

License:Apache License

private Props produceParentProperties(final ExecutableFlow flow) {
    Props parentProps = new Props();

    parentProps.put("azkaban.flow.id", flow.getId());
    parentProps.put("azkaban.flow.uuid", UUID.randomUUID().toString());

    DateTime loadTime = new DateTime();

    parentProps.put("azkaban.flow.start.timestamp", loadTime.toString());
    parentProps.put("azkaban.flow.start.year", loadTime.toString("yyyy"));
    parentProps.put("azkaban.flow.start.month", loadTime.toString("MM"));
    parentProps.put("azkaban.flow.start.day", loadTime.toString("dd"));
    parentProps.put("azkaban.flow.start.hour", loadTime.toString("HH"));
    parentProps.put("azkaban.flow.start.minute", loadTime.toString("mm"));
    parentProps.put("azkaban.flow.start.seconds", loadTime.toString("ss"));
    parentProps.put("azkaban.flow.start.milliseconds", loadTime.toString("SSS"));
    parentProps.put("azkaban.flow.start.timezone", loadTime.toString("ZZZZ"));
    return parentProps;
}

From source file:azkaban.flow.FlowUtils.java

License:Apache License

public static Props addCommonFlowProperties(final Props parentProps, final ExecutableFlowBase flow) {
    final Props props = new Props(parentProps);

    props.put(CommonJobProperties.FLOW_ID, flow.getFlowId());
    props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId());
    props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId());
    props.put(CommonJobProperties.PROJECT_NAME, flow.getProjectName());
    props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion());
    props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString());
    props.put(CommonJobProperties.PROJECT_LAST_CHANGED_BY, flow.getLastModifiedByUser());
    props.put(CommonJobProperties.PROJECT_LAST_CHANGED_DATE, flow.getLastModifiedTimestamp());
    props.put(CommonJobProperties.SUBMIT_USER, flow.getExecutableFlow().getSubmitUser());

    final DateTime loadTime = new DateTime();

    props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString());
    props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy"));
    props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM"));
    props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd"));
    props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH"));
    props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm"));
    props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss"));
    props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS"));
    props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ"));

    return props;
}

From source file:azkaban.utils.PropsUtils.java

License:Apache License

public static Props addCommonFlowProperties(Props parentProps, final ExecutableFlowBase flow) {
    Props props = new Props(parentProps);

    props.put(CommonJobProperties.FLOW_ID, flow.getFlowId());
    props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId());
    props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId());
    props.put(CommonJobProperties.PROJECT_NAME, flow.getProjectName());
    props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion());
    props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString());
    props.put(CommonJobProperties.PROJECT_LAST_CHANGED_BY, flow.getLastModifiedByUser());
    props.put(CommonJobProperties.PROJECT_LAST_CHANGED_DATE, flow.getLastModifiedTimestamp());

    DateTime loadTime = new DateTime();

    props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString());
    props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy"));
    props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM"));
    props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd"));
    props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH"));
    props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm"));
    props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss"));
    props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS"));
    props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ"));

    return props;
}

From source file:be.fedict.eid.idp.common.saml2.Saml2Util.java

License:Open Source License

private static void validateTime(DateTime now, DateTime notBefore, DateTime notOnOrAfter, int maxTimeOffset)
        throws AssertionValidationException {

    LOG.debug("now: " + now.toString());
    LOG.debug("notBefore: " + notBefore.toString());
    LOG.debug("notOnOrAfter : " + notOnOrAfter.toString());

    if (maxTimeOffset >= 0) {
        if (now.isBefore(notBefore)) {
            // time skew
            if (now.plusMinutes(maxTimeOffset).isBefore(notBefore)
                    || now.minusMinutes(maxTimeOffset).isAfter(notOnOrAfter)) {
                throw new AssertionValidationException(
                        "SAML2 assertion validation: invalid SAML message timeframe");
            }/*  w  ww . j a v  a  2 s  . c om*/
        } else if (now.isBefore(notBefore) || now.isAfter(notOnOrAfter)) {
            throw new AssertionValidationException(
                    "SAML2 assertion validation: invalid SAML message timeframe");
        }
    }
}

From source file:biz.dfch.j.graylog2.plugin.input.dfchBizExecScript.java

License:Apache License

@Override
public void launch(final Buffer buffer) throws MisfireException {
    System.out.printf("*** " + DF_PLUGIN_NAME + "::launch()\r\n");
    try {//from   w  ww .java2  s  .  c  om
        //            while(_isRunning)
        //            {
        //wait(250);

        DateTime dateTime = new DateTime();
        String msgString = String.format("%d: %s, %s", _counter.incrementAndGet(),
                _configuration.getString("DF_PLUGIN_NAME"), dateTime.toString());
        Message msg = new Message(msgString, _configuration.getString("DF_PLUGIN_NAME"), dateTime);
        buffer.insertCached(msg, dfchBizExecScript.this);
        //            }
    }
    //        catch(MisfireException ex)
    //        {
    //            LOG.error("*** " + DF_PLUGIN_NAME + "::launch() - MisfireException");
    //            ex.printStackTrace();
    //        }
    catch (Exception ex) {
        LOG.error("*** " + DF_PLUGIN_NAME + "::launch() - Exception");
        System.out.printf("*** " + DF_PLUGIN_NAME + "::launch() - Exception\r\n");
        ex.printStackTrace();
    }
}

From source file:ca.ualberta.physics.cssdp.jaxb.DateTimeAdapter.java

License:Apache License

public String marshal(DateTime v) throws Exception {
    return v.toString();
}