Example usage for org.joda.time DateTime DateTime

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

Introduction

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

Prototype

public DateTime(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:com.abuabdul.mytravelpal.util.MyTravelPalFunc.java

License:Apache License

public static final Date getUTCDateTime() {
    return new DateTime(DateTimeZone.UTC).toDate();
}

From source file:com.abuabdul.notedovn.util.NoteDovnUtil.java

License:Apache License

public static Date getUTCDateTime() {
    return new DateTime(DateTimeZone.UTC).toDate();
}

From source file:com.acc.cronjob.OldCartRemovalJob.java

License:Open Source License

@Override
public PerformResult perform(final OldCartRemovalCronJobModel job) {
    try {//from ww  w. j a  va 2  s .c  om
        if (job.getSites() == null || job.getSites().isEmpty()) {
            LOG.warn("There is no sites defined for " + job.getCode());
            return new PerformResult(CronJobResult.FAILURE, CronJobStatus.FINISHED);
        }

        final int cartAge = job.getCartRemovalAge() != null ? job.getCartRemovalAge().intValue()
                : DEFAULT_CART_MAX_AGE;
        final int anonymousCartAge = job.getAnonymousCartRemovalAge() != null
                ? job.getAnonymousCartRemovalAge().intValue()
                : DEFAULT_ANONYMOUS_CART_MAX_AGE;

        for (final BaseSiteModel site : job.getSites()) {
            for (final CartModel oldCart : getCommerceCartDao().getCartsForRemovalForSiteAndUser(
                    new DateTime(getTimeService().getCurrentTime()).minusSeconds(cartAge).toDate(), site,
                    null)) {
                getModelService().remove(oldCart);
            }

            for (final CartModel oldCart : getCommerceCartDao().getCartsForRemovalForSiteAndUser(
                    new DateTime(getTimeService().getCurrentTime()).minusSeconds(anonymousCartAge).toDate(),
                    site, getUserService().getAnonymousUser())) {
                getModelService().remove(oldCart);
            }
        }

        return new PerformResult(CronJobResult.SUCCESS, CronJobStatus.FINISHED);
    } catch (final Exception e) {
        LOG.error("Exception occurred during cart cleanup", e);
        return new PerformResult(CronJobResult.ERROR, CronJobStatus.ABORTED);
    }
}

From source file:com.ace.erp.handler.mybatis.JodaDateTimeDateTypeHandler.java

@Override
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
    DateTime dateTime = null;//from ww  w.  ja  v  a 2 s .c o m
    Date date = rs.getDate(columnName);
    if (date != null) {
        dateTime = new DateTime(date.getTime());
    }
    return dateTime;
}

From source file:com.ace.erp.handler.mybatis.JodaDateTimeDateTypeHandler.java

@Override
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    DateTime dateTime = null;/*from  www  .  j av a 2  s .  c o  m*/
    Date date = cs.getDate(columnIndex);
    if (date != null) {
        dateTime = new DateTime(date.getTime());
    }
    return dateTime;
}

From source file:com.ace.erp.handler.mybatis.JodaDateTimeDateTypeHandler.java

public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
    DateTime dateTime = null;// ww  w . j  av  a  2 s .  c o m
    Date date = rs.getDate(columnIndex);
    if (date != null) {
        dateTime = new DateTime(date.getTime());
    }
    return dateTime;
}

From source file:com.ace.erp.handler.mybatis.JodaDateTimestampTypeHandler.java

@Override
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
    DateTime dateTime = null;/* w w  w.  java2 s  .co  m*/
    Timestamp timestamp = rs.getTimestamp(columnName);
    if (timestamp != null) {
        dateTime = new DateTime(timestamp.getTime());
    }
    return dateTime;
}

From source file:com.ace.erp.handler.mybatis.JodaDateTimestampTypeHandler.java

@Override
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
    DateTime dateTime = null;/*  ww w  . java 2  s. c  o  m*/
    Timestamp timestamp = cs.getTimestamp(columnIndex);
    if (timestamp != null) {
        dateTime = new DateTime(timestamp.getTime());
    }
    return dateTime;
}

From source file:com.ace.erp.handler.mybatis.JodaDateTimestampTypeHandler.java

public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
    DateTime dateTime = null;/*  www. ja v a 2s.co  m*/
    Timestamp timestamp = rs.getTimestamp(columnIndex);
    if (timestamp != null) {
        dateTime = new DateTime(timestamp.getTime());
    }
    return dateTime;
}

From source file:com.actimem.blog.gson.custometypeannotation.DateTimeTypeAdapter.java

License:Apache License

@Override
public DateTime read(JsonReader in) throws IOException {
    return new DateTime(in.nextString());
}