Example usage for org.joda.time LocalDateTime toDateTime

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

Introduction

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

Prototype

public DateTime toDateTime() 

Source Link

Document

Converts this object to a DateTime using the default zone.

Usage

From source file:energy.usef.agr.model.SynchronisationConnection.java

License:Apache License

public void setLastSynchronisationTime(LocalDateTime lastSynchronisationTime) {
    if (lastSynchronisationTime == null) {
        this.lastSynchronisationTime = null;
    } else {//from w  w w .j  a  va  2 s .  c o m
        this.lastSynchronisationTime = lastSynchronisationTime.toDateTime().toDate();
    }
}

From source file:energy.usef.agr.model.SynchronisationConnection.java

License:Apache License

public void setLastModificationTime(LocalDateTime lastModificationTime) {
    if (lastModificationTime == null) {
        this.lastModificationTime = null;
    } else {/*from  w w w .j  a v  a 2  s .c o  m*/
        this.lastModificationTime = lastModificationTime.toDateTime().toDate();
    }
}

From source file:energy.usef.core.model.Message.java

License:Apache License

public void setCreationTime(LocalDateTime creationTime) {
    if (creationTime == null) {
        this.creationTime = null;
    } else {//from   www  .  j a va 2  s.  c o m
        this.creationTime = creationTime.toDateTime().toDate();
    }
}

From source file:energy.usef.core.model.PlanboardMessage.java

License:Apache License

public void setExpirationDate(LocalDateTime expirationDate) {
    if (expirationDate == null) {
        this.expirationDate = null;
    } else {/*  w  w w.j  a v a 2  s . c om*/
        this.expirationDate = expirationDate.toDateTime().toDate();
    }
}

From source file:energy.usef.core.model.PlanboardMessage.java

License:Apache License

public void setCreationDateTime(LocalDateTime creationDateTime) {
    if (creationDateTime == null) {
        this.creationDateTime = null;
    } else {//  ww w  .  ja v  a2s .c  o m
        this.creationDateTime = creationDateTime.toDateTime().toDate();
    }
}

From source file:energy.usef.core.repository.PlanboardMessageRepository.java

License:Apache License

/**
 * This method finds {@link PlanboardMessage} based on {@link DocumentType} and {@link DocumentStatus}.
 *
 * @param localDateTime  The LocalDateTime the message should be before.
 * @param documentType   The type of document, like request, offer or order.
 * @param documentStatus The status of document, like new, submitted or rejected.
 * @return The list of {@link PlanboardMessage} which have a specific {@link DocumentType} and {@link DocumentStatus}.
 *//* w w  w  .  j  a v a 2  s . com*/
@SuppressWarnings("unchecked")
public List<PlanboardMessage> findPlanboardMessagesOlderThan(LocalDateTime localDateTime,
        DocumentType documentType, DocumentStatus documentStatus) {
    Query query = entityManager
            .createQuery("SELECT pbm FROM PlanboardMessage pbm WHERE pbm.documentType = :documentType "
                    + "AND pbm.documentStatus = :documentStatus AND pbm.creationDateTime < :localDateTime");
    query.setParameter("documentStatus", documentStatus);
    query.setParameter("documentType", documentType);
    query.setParameter("localDateTime", localDateTime.toDateTime().toDate());
    return query.getResultList();
}

From source file:energy.usef.core.util.DateTimeUtil.java

License:Apache License

/**
 * Gets the number of milliseconds until the next occurence of the local time (which is the current day or the day after).
 *
 * @param localTime {@link LocalTime}/*  w  w  w  .j a  v a 2s  . co  m*/
 * @return the number of milliseconds.
 */
public static Long millisecondDelayUntilNextTime(LocalTime localTime) {
    LocalDateTime schedule = getCurrentDateWithTime(localTime);
    if (schedule.isBefore(getCurrentDateTime())) {
        schedule = schedule.plusDays(1);
    }
    return new Duration(getCurrentDateTime().toDateTime(), schedule.toDateTime()).getMillis();
}

From source file:energy.usef.core.util.DateTimeUtil.java

License:Apache License

/**
 * Calculate the number of minutes from midnight to now. The number of minutes depends on summer- and winter time.
 *
 * @param dateTime the date time which includes the timezone. When setting the DateTime with the default constructor, the
 * default timezone where the application runs, is used.
 * @return the number of minutes from midnight.
 *//* w w w.  j av a2s .c o  m*/
public static Integer getElapsedMinutesSinceMidnight(LocalDateTime dateTime) {
    DateTime midnight = dateTime.toLocalDate().toDateMidnight().toDateTime();
    Duration duration = new Interval(midnight, dateTime.toDateTime()).toDuration();
    return (int) duration.getStandardSeconds() / SECONDS_PER_MINUTE;
}

From source file:energy.usef.dso.model.ConnectionCapacityLimitationPeriod.java

License:Apache License

public void setStartDateTime(LocalDateTime startDateTime) {
    if (startDateTime == null) {
        this.startDateTime = null;
    } else {/*from w  w  w  .  ja  va 2 s.  co m*/
        this.startDateTime = startDateTime.toDateTime().toDate();
    }
}

From source file:energy.usef.dso.model.ConnectionCapacityLimitationPeriod.java

License:Apache License

public void setEndDateTime(LocalDateTime endDateTime) {
    if (endDateTime == null) {
        this.endDateTime = null;
    } else {/*from  w w w. j  av a 2  s. c o m*/
        this.endDateTime = endDateTime.toDateTime().toDate();
    }
}