Example usage for org.joda.time LocalDateTime getMillisOfDay

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

Introduction

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

Prototype

public int getMillisOfDay() 

Source Link

Document

Get the millis of day field value.

Usage

From source file:com.vaushell.superpipes.nodes.buffer.Slot.java

License:Open Source License

/**
 * Create a slot and parse value.//from  ww w.  ja  va2s  .  com
 *
 * @param days List of days, separated by a comma.
 * @param start Inclusive starting hour (format: HH:mm:ss)
 * @param end Exclusive ending hour (format: HH:mm:ss)
 * @return the slot
 */
public static Slot parse(final String days, final String start, final String end) {
    // Days
    final DateTimeFormatter fmtDay = DateTimeFormat.forPattern("E");

    final TreeSet<Integer> rDays = new TreeSet<>();
    for (final String sDay : days.split(",")) {
        final int dayOfWeek = fmtDay.parseLocalDate(sDay).getDayOfWeek();

        rDays.add(dayOfWeek);
    }

    // Hours (HH:mm:ss)
    final DateTimeFormatter fmtHour = DateTimeFormat.forPattern("HH:mm:ss");

    final LocalDateTime min = fmtHour.parseLocalDateTime(start).withMillisOfSecond(0);
    final LocalDateTime max = fmtHour.parseLocalDateTime(end).withMillisOfSecond(0);

    return new Slot(rDays, min.getMillisOfDay(), max.getMillisOfDay());
}

From source file:de.javakaffee.kryoserializers.jodatime.JodaLocalDateTimeSerializer.java

License:Apache License

@Override
public void write(Kryo kryo, Output output, LocalDateTime localDateTime) {
    final int packedYearMonthDay = localDateTime.getYear() * 13 * 32 + localDateTime.getMonthOfYear() * 32
            + localDateTime.getDayOfMonth();
    output.writeLong((long) packedYearMonthDay * 86400000 + localDateTime.getMillisOfDay(), true);
    final String chronologyId = IdentifiableChronology.getChronologyId(localDateTime.getChronology());
    output.writeString(chronologyId == null ? "" : chronologyId);
}

From source file:de.jpaw.bonaparte.util.DayTime.java

License:Apache License

/** Computes the difference between two LocalDateTime instances with millisecond precision.
 * Unfortunately the method getLocalMillis() which returns the time since the epoch is protected (as of JodaTime 2.1),
 * therefore we have to use the millis of a day ad work around the day wrap. (This is a solution for short time periods only!)
 * TODO: Should test that (by comparing start + 23 hours with end, and throwing an exception if start + 23 hours is still < end).
 *///from  w ww .  jav a 2  s .com
static public int LocalDateTimeDifference(LocalDateTime start, LocalDateTime end) {
    long t0 = start.getMillisOfDay();
    long t1 = end.getMillisOfDay();
    if (t0 > t1) {
        return (int) ((t1 + 86400000L) - t0);
    }
    return (int) (t1 - t0);
}

From source file:org.kuali.kpme.core.api.util.jaxb.LocalDateTimeAdapter.java

License:Educational Community License

@Override
public Calendar marshal(LocalDateTime localTime) throws Exception {
    if (localTime == null) {
        return null;
    }/*from  w  w w .j  a va 2 s . c  o m*/
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(localTime.getMillisOfDay());
    return calendar;
}