Example usage for org.joda.time LocalDate toDateTime

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

Introduction

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

Prototype

public DateTime toDateTime(LocalTime time) 

Source Link

Document

Converts this object to a DateTime using a LocalTime to fill in the missing fields and using the default time zone.

Usage

From source file:es.usc.citius.servando.calendula.persistence.Schedule.java

License:Open Source License

public DateTime startDateTime() {
    LocalDate s = start != null ? start : LocalDate.now();
    LocalTime t = startTime != null ? startTime : LocalTime.MIDNIGHT;
    return s.toDateTime(t);
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

public void onDelayHourlySchedule(Schedule s, LocalTime t, LocalDate date, Context ctx) {
    if (isWithinDefaultMargins(date.toDateTime(t), ctx)) {
        setRepeatAlarm(s, AlarmIntentParams.forSchedule(s.getId(), t, date, true), ctx,
                getAlarmRepeatFreq(ctx) * 60 * 1000);
    }// w w w . j  a  va  2 s. co  m
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

public boolean isWithinDefaultMargins(Routine r, LocalDate date, Context cxt) {
    return isWithinDefaultMargins(date.toDateTime(r.time()), cxt);
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

/**
 * Set an alarm for a routine//  ww  w.java2  s.  c  om
 */
private void setFirstAlarm(Routine routine, LocalDate date, Context ctx) {
    long timestamp = date.toDateTime(routine.time()).getMillis();
    PendingIntent routinePendingIntent = pendingIntent(ctx, routine, date, false, AlarmIntentParams.AUTO);
    setExactAlarm(ctx, timestamp, routinePendingIntent);
}

From source file:es.usc.citius.servando.calendula.scheduling.AlarmScheduler.java

License:Open Source License

/**
 * Set an alarm for a repeating schedule item
 *//*  w ww  . j ava 2  s. c o m*/
private void setFirstAlarm(Schedule schedule, LocalTime time, LocalDate date, Context ctx) {
    DateTime dateTime = date.toDateTime(time);
    PendingIntent routinePendingIntent = pendingIntent(ctx, schedule, time, date, false,
            AlarmIntentParams.AUTO);
    setExactAlarm(ctx, dateTime.getMillis(), routinePendingIntent);
}

From source file:fi.hsl.parkandride.core.service.FacilityHistoryService.java

License:EUPL

private static Interval windowForDate(LocalDate date) {
    return new Interval(date.toDateTime(WINDOW_START), date.toDateTime(WINDOW_END));
}

From source file:module.mission.domain.util.MissionProcessCreationBean.java

License:Open Source License

public MissionProcessCreationBean(final Boolean grantOwnerEquivalence) {
    this.grantOwnerEquivalence = grantOwnerEquivalence;

    final LocalDate today = new LocalDate().plusDays(16);
    final LocalTime defaultStart = new LocalTime(9, 0, 0);
    final LocalTime defaultEnd = new LocalTime(18, 0, 0);
    daparture = today.toDateTime(defaultStart);
    arrival = today.toDateTime(defaultEnd);
}

From source file:orc.lib.orchard.forms.DateTimeRangesField.java

License:Open Source License

private void renderHour(final PrintWriter out, final int hour) throws IOException {
    out.write("<tr>");
    out.write("<th>");
    out.write(formatHour(hour));/* w  ww  .  j av  a 2s .  c o  m*/
    out.write("</th>");
    LocalDate current = span.getStart();
    final LocalDate end = span.getEnd();
    final LocalTime time = new LocalTime(hour, 0);
    while (current.compareTo(end) < 0) {
        out.write("<td>");
        renderTime(out, current.toDateTime(time));
        out.write("</td>");
        current = current.plusDays(1);
    }
    out.write("</tr>");
}

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.DateColumnLocalDateMapper.java

License:Apache License

@Override
public Date toNonNullValue(LocalDate value) {

    if (databaseZone == null) {
        return Date.valueOf(LOCAL_DATE_FORMATTER.print((LocalDate) value));
    }//from   w  w  w .  j a  v a2 s.com

    DateTime zonedValue = value.toDateTime(value.toDateTimeAtStartOfDay());

    final Date date = new Date(zonedValue.getMillis());
    return date;
}

From source file:org.kitodo.production.plugin.opac.pica.PicaPlugin.java

License:Open Source License

/**
 * The function createResult() creates a Map&lt;String, Object&gt; as result
 * of getHit(). The map contains the full hit as "fileformat", the docType
 * as "type" and some bibliographic metadata for Production to be able to
 * show a short hit display as supposed in
 * {@link org.goobi.production.plugin.CataloguePlugin.Hit}
 *
 * @param docType/*w  ww  . java 2  s . c om*/
 *            the DocType of the hit
 * @param hit
 *            the hit data as JDom Element
 * @param fileformat
 *            the hit data as Fileformat
 * @return a Map with the hit
 */
private static Map<String, Object> createResult(String docType, Element hit, Fileformat fileformat) {
    final LocalTime DAY_END = new LocalTime(23, 59, 59, 999);

    Map<String, Object> result = new HashMap<>(20);
    LocalDate today = new LocalDate();

    result.put("fileformat", fileformat);
    result.put("type", docType);

    // add some basic metadata
    String accessed = getElementFieldValue(hit, "208@", "a");
    try {
        LocalDate date = toRecentLocalDate(accessed, today);
        result.put("accessed", date.toDateTime(date.isEqual(today) ? new LocalTime() : DAY_END).toString());
    } catch (RuntimeException e) {
        logger.error(e);
    }

    String lastName = getElementFieldValue(hit, "028A", "a");
    if (lastName.equals("")) {
        lastName = getElementFieldValue(hit, "028A", "l");
    }
    String firstName = getElementFieldValue(hit, "028A", "d");
    if (firstName.equals("")) {
        firstName = getElementFieldValue(hit, "028A", "P");
    }
    String middleTitle = getElementFieldValue(hit, "028A", "c");
    String author = lastName + (!firstName.equals("") ? ", " : "") + firstName
            + (!middleTitle.equals("") ? " " : "") + middleTitle;
    if (author.equals("")) {
        author = getElementFieldValue(hit, "028A", "8");
    }
    if (author.equals("")) {
        String lastName2 = getElementFieldValue(hit, "028C", "a");
        if (lastName2.equals("")) {
            lastName2 = getElementFieldValue(hit, "028C", "l");
        }
        String firstName2 = getElementFieldValue(hit, "028C", "d");
        if (firstName2.equals("")) {
            firstName2 = getElementFieldValue(hit, "028C", "P");
        }
        String middleTitle2 = getElementFieldValue(hit, "028C", "c");
        author = lastName2 + (!firstName2.equals("") ? ", " : "") + firstName2
                + (!middleTitle2.equals("") ? " " : "") + middleTitle2;
    }
    result.put("creator", author);

    String date = getElementFieldValue(hit, "201B", "0");
    try {
        LocalDate localDate = toRecentLocalDate(date, today);
        result.put("date", localDate.toString());
    } catch (RuntimeException e) {
        logger.error(e);
    }

    result.put("edition", getElementFieldValue(hit, "032@", "a"));
    result.put("format", docType.startsWith("O") ? "internet" : "monograph");
    result.put("number", getElementFieldValue(hit, "036E", "l"));
    result.put("place", getElementFieldValue(hit, "033A", "p"));
    result.put("publisher", getElementFieldValue(hit, "033A", "n"));
    result.put("series", getElementFieldValue(hit, "036E", "a"));

    String subseries = getElementFieldValue(hit, "021A", "d");
    if (subseries == null || subseries.length() == 0) {
        subseries = getElementFieldValue(hit, "021B", "d");
    }
    if (subseries == null || subseries.length() == 0) {
        subseries = getElementFieldValue(hit, "027D", "d");
    }
    result.put("subseries", subseries);

    String title = getElementFieldValue(hit, "021A", "a");
    if (title == null || title.length() == 0) {
        title = getElementFieldValue(hit, "021B", "a");
    }
    if (title == null || title.length() == 0) {
        title = getElementFieldValue(hit, "027D", "a");
    }
    String titleLong = getElementFieldValue(hit, "021A", "d");
    if (titleLong != null && titleLong.length() > 0) {
        title = title + " : " + titleLong;
    }
    result.put("title", title.replaceAll("@", ""));

    result.put("url", getElementFieldValue(hit, "209R", "a"));
    result.put("year", getElementFieldValue(hit, "011@", "a"));
    return result;
}