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:com.jbirdvegas.mgerrit.search.AgeSearch.java

License:Apache License

@Override
public String getGerritQuery(ServerVersion serverVersion) {
    String operator = getOperator();

    if ("<=".equals(operator) || "<".equals(operator)) {
        return BeforeSearch._getGerritQuery(this, serverVersion);
    } else if (">=".equals(operator) || ">".equals(operator)) {
        return AfterSearch._getGerritQuery(this, serverVersion);
    }// w ww.  j a v  a2 s . c om

    if (serverVersion != null && serverVersion.isFeatureSupported(ServerVersion.VERSION_BEFORE_SEARCH)
            && mInstant != null) {
        // Use a combination of before and after to get an interval
        if (mPeriod == null) {
            mPeriod = new Period(mInstant, Instant.now());
        }
        DateTime now = new DateTime();
        DateTime earlier = now.minus(adjust(mPeriod, +1));
        DateTime later = now.minus(mPeriod);

        SearchKeyword newer = new AfterSearch(earlier.toString());
        SearchKeyword older = new BeforeSearch(later.toString());
        return newer.getGerritQuery(serverVersion) + "+" + older.getGerritQuery(serverVersion);
    } else {
        // Need to leave off the operator and make sure we are using relative format
        /* Gerrit only supports specifying one time unit, so we will normalize the period
         *  into days.  */
        return OP_NAME + ":" + String.valueOf(toDays()) + "d";
    }
}

From source file:com.keithandthegirl.api.google.DateConverter.java

License:Open Source License

@Override
public DateTime read(InputNode node) throws Exception {
    Log.d(TAG, "read : enter");

    DateTime date = formatter.parseDateTime(node.getValue());
    Log.v(TAG, "read : date=" + date.toString());

    Log.d(TAG, "read : exit");
    return date;//w ww  .  j  a  va  2s .  co m
}

From source file:com.keithandthegirl.api.google.WhenConverter.java

License:Open Source License

@Override
public When read(InputNode node) throws Exception {
    Log.d(TAG, "read : enter");

    String endTime = node.getAttribute("endTime").getValue();
    String startTime = node.getAttribute("startTime").getValue();

    DateTime endDate = formatter.parseDateTime(endTime);
    Log.v(TAG, "read : endDate=" + endDate.toString());

    DateTime startDate = formatter.parseDateTime(startTime);
    Log.v(TAG, "read : startDate=" + startDate.toString());

    Log.d(TAG, "read : exit");
    return new When(endDate, startDate);
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.message.MMXChannelSummary.java

License:Apache License

public MMXChannelSummary(String userId, String channelName, int publishedItemCount, Date lastPublishedItem) {
    this.userId = userId;
    this.channelName = channelName;
    this.publishedItemCount = publishedItemCount;
    DateTime d = new DateTime(lastPublishedItem, DateTimeZone.UTC);
    this.lastPublishedTime = d.toString();
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.message.MMXChannelSummary.java

License:Apache License

public MMXChannelSummary(String channelName, int publishedItemCount, Date lastPublishedItem) {
    this.channelName = channelName;
    this.publishedItemCount = publishedItemCount;
    DateTime d = new DateTime(lastPublishedItem, DateTimeZone.UTC);
    this.lastPublishedTime = d.toString();
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.message.MMXTopicSummary.java

License:Apache License

public MMXTopicSummary(String topicName, int publishedItemCount, Date lastPublishedItem) {
    this.topicName = topicName;
    this.publishedItemCount = publishedItemCount;
    DateTime d = new DateTime(lastPublishedItem, DateTimeZone.UTC);
    this.lastPublishedTime = d.toString();
}

From source file:com.marklogic.samplestack.dbclient.DateFacetBuilder.java

License:Apache License

private DateFacetBuilder bucket(DateTime ge, DateTime lt) {
    ObjectNode thisBucket = this.bucketNode.addObject();
    thisBucket.put("ge", ge.toString());
    thisBucket.put("lt", lt.toString());
    thisBucket.put("name", ge.toString());
    thisBucket.put("label", ge.toString());
    return this;
}

From source file:com.masood.facebookevents.FacebookEvents.java

public static String dateConversion(Date incomingdate) throws ParseException {

    //        String dateString = "2013-05-30T19:30:00+0300";
    //        Sat May 02 10:00:00 IST 2015
    //        Sat Jan 25 16:52:28 PST 2014
    //        System.out.println(incomingdate);
    DateTime startdate = new DateTime(incomingdate);

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    String temp = startdate.toString();
    temp = temp.substring(0, 19) + temp.substring(23, 26) + temp.substring(27, 29);
    java.util.Date date = dateFormat.parse(temp);

    dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    String formatedDate = dateFormat.format(date);
    System.out.println("formated: " + formatedDate);
    //        date = dateFormat.parse(formatedDate);

    return formatedDate;

}

From source file:com.medvision360.medrecord.server.query.QueryEHRServerResource.java

License:Creative Commons License

@Override
public IDList ehrQuery() throws RecordException // todo efficient/fully indexed ehrQuery()
{
    String excludeDeletedString = getQueryValue("excludeDeleted");
    boolean hasDeleted = excludeDeletedString != null;
    boolean excludeDeleted = hasDeleted && "true".equals(excludeDeletedString);
    String excludeEmptyString = getQueryValue("excludeEmpty");
    boolean excludeEmpty = "true".equals(excludeEmptyString);
    List<String> systemIDList = getQueryValues("systemID");
    boolean hasSystemID = systemIDList.size() > 0;
    String subjectString = getQueryValue("subject");
    boolean hasSubject = subjectString != null;
    DateTime createdBefore = getDateTimeQueryValue("createdBefore");
    boolean hasCreatedBefore = createdBefore != null;
    DateTime createdAfter = getDateTimeQueryValue("createdAfter");
    boolean hasCreatedAfter = createdAfter != null;

    if (hasCreatedBefore && hasCreatedAfter && createdBefore.isBefore(createdAfter)) {
        throw new InvalidRangeException(
                String.format("createdBefore %s < createdAfter %s, cannot ever match anything",
                        createdBefore.toString(), createdAfter.toString()));
    }/*w  w w .j  av a 2  s . co  m*/

    try {
        Iterable<HierObjectID> list;
        if (hasDeleted) {
            list = engine().getEHRStore().list(excludeDeleted);
        } else {
            list = engine().getEHRStore().list();
        }

        // filters organized by guess of which filter is cheaper

        // note this assumes store implementations do some caching (like BaseXEHRStore does),
        // otherwise, this kind of code could get pretty expensive in terms of # of database queries

        if (hasSubject || hasCreatedBefore || hasCreatedAfter || hasSystemID) {
            list = Iterables.filter(list, new EHRPropertyPredicate(engine(), subjectString, createdBefore,
                    createdAfter, systemIDList));
        }
        if (excludeEmpty) {
            list = Iterables.filter(list, new NonEmptyEHRPredicate(engine()));
        }

        IDList result = toIdList(list);
        return result;
    } catch (IOException e) {
        throw new IORecordException(e.getMessage(), e);
    }
}

From source file:com.melexis.esb.EventDaoCassandraImpl.java

License:Apache License

public List<Event> findEvents(String source, DateTime start, DateTime end, int max) {

    String from = (start == null) ? "" : start.toString();
    String till = (end == null) ? "" : end.toString();

    SuperSliceQuery<String, String, String, String> query = createSuperSliceQuery(keyspace, SERIALIZER,
            SERIALIZER, SERIALIZER, SERIALIZER).setColumnFamily(columnFamily).setKey(source);

    if ((till.compareTo(from) > 0) || till.equals("")) {
        query.setRange(from, till, false, max);
    } else {//  w ww  .j  a  va 2  s  .  c  om
        // return rows in reverse order
        query.setRange(from, till, true, max);
    }

    List<HSuperColumn<String, String, String>> rows = query.execute().get().getSuperColumns();

    return Lists.transform(rows, new SuperColumnToEventConverter(source));
}