Example usage for org.joda.time Instant toDateTime

List of usage examples for org.joda.time Instant toDateTime

Introduction

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

Prototype

public DateTime toDateTime(DateTimeZone zone) 

Source Link

Document

Get this object as a DateTime using the same chronology but a different zone.

Usage

From source file:com.moss.joda.time.xml.InstantAdapter.java

License:Open Source License

@Override
public String marshal(Instant arg0) throws Exception {
    if (arg0 == null)
        return null;
    return format.print(arg0.toDateTime(DateTimeZone.UTC));
}

From source file:com.moss.jodapersist.YearMonthDayUserType.java

License:Open Source License

public void nullSafeSet(PreparedStatement statement, Object value, int index)
        throws HibernateException, SQLException {
    YearMonthDay ymd = (YearMonthDay) value;

    if (ymd != null) {
        if (sqltype.equals(this.DB_FORMAT_NUMERIC)) {
            statement.setLong(index, yearMonthDayToLong(ymd));
        } else if (sqltype.equals(this.DB_FORMAT_DATETIME)) {
            Instant instant = ymd.toDateTimeAtMidnight().toInstant();

            if (timeOffset.equals(TIME_OFFSET_NOON)) {
                instant = instant.toDateTime(DateTimeZone.UTC).plusHours(12).toInstant();
            }/*from w  w  w . ja  va  2 s  .  c o m*/

            statement.setTimestamp(index, new Timestamp(instant.getMillis()), storageCalendar);
        } else if (sqltype.equals(this.DB_FORMAT_STRING)) {
            statement.setString(index, ymd.toString());
        } else
            throw new Error("No valid sqlType specified!");
    } else {
        statement.setNull(index, getNullType());
    }
}

From source file:org.powertac.customer.AbstractCustomer.java

License:Apache License

protected Instant lastSunday() {
    Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant();
    return start.toDateTime(DateTimeZone.UTC).withDayOfWeek(1).withHourOfDay(0).toInstant();
}

From source file:org.powertac.customer.AbstractCustomer.java

License:Apache License

protected Instant startOfDay() {
    Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant();
    return start.toDateTime(DateTimeZone.UTC).withHourOfDay(0).toInstant();
}

From source file:org.powertac.customer.AbstractCustomer.java

License:Apache License

protected Instant nextStartOfDay() {
    Instant start = service.getTimeslotRepo().currentTimeslot().getStartInstant();
    return start.toDateTime(DateTimeZone.UTC).withHourOfDay(0).toInstant().plus(TimeService.DAY);
}