Example usage for org.joda.time DateTime getMillisOfDay

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

Introduction

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

Prototype

public int getMillisOfDay() 

Source Link

Document

Get the millis of day field value.

Usage

From source file:ch.emad.business.schuetu.BusinessImpl.java

License:Apache License

public SpielEinstellungen saveEinstellungen(SpielEinstellungen einstellungenNeu) {

    if (einstellungenNeu == null) {
        return null;
    }//w ww  . j a v a2s.  c o m

    if (verarbeiter.isFertig()) {
        einstellungenNeu.setPhase(SpielPhasenEnum.G_ABGESCHLOSSEN);
    }

    // spieldatum auf 0 Uhr zuruecksetzen
    DateTime time = new DateTime(einstellungenNeu.getStarttag());
    final int millis = time.getMillisOfDay();
    time = time.minusMillis(millis);
    einstellungenNeu.setStarttag(new Date(time.getMillis()));

    this.spielEinstellungenRepo.save(einstellungenNeu);

    return spielEinstellungenRepo.getEinstellungen();
}

From source file:ch.emad.business.schuetu.BusinessImpl.java

License:Apache License

private List<SpielZeile> createZeilen(DateTime startIn, final boolean sonntag) {
    DateTime start = startIn;

    final int millis = start.getMillisOfDay();

    start = start.minusMillis(millis);/*ww  w . ja va  2 s  . co m*/

    start = start.plusHours(8);

    final DateTime end = start.plusHours(11);

    final List<SpielZeile> zeilen = new ArrayList<SpielZeile>();
    while (start.isBefore(end.getMillis())) {
        final SpielZeile zeile = new SpielZeile();

        if (start.getHourOfDay() == 8) {
            zeile.setPause(true);
        }

        if (start.getHourOfDay() == MITTAG) {
            zeile.setPause(true);
        }

        if ((start.getHourOfDay() > MITTAG) && sonntag) {
            zeile.setFinale(true);
        }

        // wunsch enum wird gesetzt um spaeter die kategorie gegenpruefen zu koennen
        if (sonntag && (start.getHourOfDay() <= MITTAG)) {
            zeile.setSpieltageszeit(SpielTageszeit.SONNTAGMORGEN);
        }
        if (!sonntag && (start.getHourOfDay() < MITTAG)) {
            zeile.setSpieltageszeit(SpielTageszeit.SAMSTAGMORGEN);
        }
        if (!sonntag && (start.getHourOfDay() > MITTAG)) {
            zeile.setSpieltageszeit(SpielTageszeit.SAMSTAGNACHMITTAG);
        }

        zeile.setStart(start.toDate());
        zeilen.add(zeile);

        final DateTimeZone zone = start.getZone();
        BusinessImpl.LOG.info("zone: " + zone + " date: " + start.toDate());

        zeile.setSonntag(sonntag);

        start = start.plusMinutes(
                this.getSpielEinstellungen().getPause() + this.getSpielEinstellungen().getSpiellaenge());
    }
    return zeilen;
}

From source file:com.almende.eve.agent.google.GoogleCalendarAgent.java

License:Apache License

/**
 * Get todays events. A convenience method for easy testing
 * //from   w w  w. j a  v  a  2 s. c o m
 * @param calendarId
 *            the calendar id
 * @return the events today
 * @throws Exception
 *             the exception
 */
public ArrayNode getEventsToday(@Optional @Name("calendarId") final String calendarId) throws Exception {
    final DateTime now = DateTime.now();
    final DateTime timeMin = now.minusMillis(now.getMillisOfDay());
    final DateTime timeMax = timeMin.plusDays(1);

    return getEvents(timeMin.toString(), timeMax.toString(), calendarId);
}

From source file:com.almende.eve.agent.google.GoogleCalendarAgent.java

License:Apache License

/**
 * Get busy intervals of today. A convenience method for easy testing
 * /*from w ww . ja v  a  2 s  .  co  m*/
 * @param calendarId
 *            optional calendar id. If not provided, the default calendar is
 *            used
 * @param timeZone
 *            Time zone used in the response. Optional. The default is UTC.
 * @return the busy today
 * @throws Exception
 *             the exception
 */
public ArrayNode getBusyToday(@Optional @Name("calendarId") final String calendarId,
        @Optional @Name("timeZone") final String timeZone) throws Exception {
    final DateTime now = DateTime.now();
    final DateTime timeMin = now.minusMillis(now.getMillisOfDay());
    final DateTime timeMax = timeMin.plusDays(1);

    return getBusy(timeMin.toString(), timeMax.toString(), calendarId, timeZone);
}

From source file:com.almende.pi5.lch.DERSimAgent.java

License:Apache License

private double getTimePercentage(DateTime when) {
    final int currentTime = when.getMillisOfDay() / 1000;
    double res = 0;
    for (Timestep ts : timespread) {
        res = ts.getUsagePercentage();/*from  ww  w. j  a v a 2  s . co  m*/
        if (ts.getSecondsOfDay() > currentTime) {
            break;
        }
    }
    return res;
}

From source file:com.bluexml.xforms.controller.mapping.MappingToolCommon.java

License:Open Source License

/**
 * Gets the date time from date and time.
 * //from   ww  w  .  j av  a2  s . c o m
 * @param date
 *            the date
 * @param time
 *            the time
 * @return the date time from date and time
 */
protected String getDateTimeFromDateAndTime(String date, String time) {
    DateTime rdate = new DateTime(DatatypeConverter.parseDate(date));
    DateTime rtime = new DateTime(DatatypeConverter.parseTime(time));
    long millis = rdate.getMillis() - rdate.getMillisOfDay() + rtime.getMillisOfDay();
    return DateTimeConverter.convert_XFormsToAlfresco_DateTime(millis);
}

From source file:com.digitald4.iis.model.License.java

License:Open Source License

public static List<License> getAlarming(EntityManager entityManager) {
    DateTime window = DateTime.now().plusDays(30);
    window = window.minusMillis(window.getMillisOfDay());
    List<License> alarming = new ArrayList<License>();
    for (License license : getCollection(License.class, entityManager,
            "SELECT o FROM License o WHERE o.EXPIRATION_DATE <= ?1", window.toDate())) {
        if ((license.isExpired() || license.isWarning())
                && license.getNurse().getStatus() == GenData.NURSE_STATUS_ACTIVE.get(entityManager)) {
            alarming.add(license);//w  w  w.  j a v a  2 s . c  o  m
        }
    }
    return alarming;
}

From source file:com.egt.core.util.STP.java

License:Open Source License

public static String getString(Object obj) {
    if (obj == null) {
        return null;
    } else if (obj instanceof String) {
        return obj.toString();
    } else if (obj instanceof Integer) {
        return obj.toString();
    } else if (obj instanceof Long) {
        return obj.toString();
    } else if (obj instanceof BigInteger) {
        return obj.toString();
    } else if (obj instanceof BigDecimal) {
        /*//from  www  . j a va 2s .  c  o m
         * OJO: configuracion regional (signo, punto y coma)
         */
        return obj.toString();
    } else if (obj instanceof Boolean) {
        return obj.toString();
    } else if (obj instanceof Date) {
        /*
         * OJO: configuracion regional
         */
        return new DateTime(obj).toString("dd/MM/yyyy");
    } else if (obj instanceof Time) {
        /*
         * OJO: configuracion regional
         */
        return new DateTime(obj).toString("hh:mm aa");
    } else if (obj instanceof Timestamp || obj instanceof java.util.Date) {
        /*
         * OJO: configuracion regional
         */
        DateTime datetime = new DateTime(obj);
        String pattern = datetime.getMillisOfDay() == 0 ? "dd/MM/yyyy" : "dd/MM/yyyy hh:mm:ss aa";
        return datetime.toString(pattern);
    } else {
        return obj.toString();
    }
}

From source file:com.google.android.apps.paco.Experiment.java

License:Open Source License

@JsonIgnore
public DateTime getEndDateTime() {
    DateTime lastTime = null;// w w w . j av a  2 s.  co  m
    for (SignalingMechanism signalingMechanism : getSignalingMechanisms()) {
        DateTime lastTimeForSignalGroup = null;
        if (signalingMechanism instanceof SignalSchedule) {
            SignalSchedule schedule = (SignalSchedule) signalingMechanism;
            if (schedule.getScheduleType().equals(SignalSchedule.WEEKDAY)) {
                List<SignalTime> times = schedule.getSignalTimes();
                SignalTime lastSignalTime = times.get(times.size() - 1);
                if (lastSignalTime.getType() == SignalTimeDAO.FIXED_TIME) {
                    // TODO actually compute the last time based on all of the rules for offset times and skip if missed rules
                    DateTime lastTimeForDay = new DateTime()
                            .plus(lastSignalTime.getFixedTimeMillisFromMidnight());
                    lastTimeForSignalGroup = new DateMidnight(TimeUtil.unformatDate(getEndDate())).toDateTime()
                            .withMillisOfDay(lastTimeForDay.getMillisOfDay());
                } else {
                    lastTimeForSignalGroup = new DateMidnight(TimeUtil.unformatDate(getEndDate())).plusDays(1)
                            .toDateTime();
                }
            } else {
                lastTimeForSignalGroup = new DateMidnight(TimeUtil.unformatDate(getEndDate())).plusDays(1)
                        .toDateTime();
            }
        } else {
            lastTimeForSignalGroup = new DateMidnight(TimeUtil.unformatDate(getEndDate())).plusDays(1)
                    .toDateTime();
        }
        if (lastTime == null || lastTimeForSignalGroup.isAfter(lastTime)) {
            lastTime = lastTimeForSignalGroup;
        }
    }
    return lastTime;
}

From source file:com.google.android.apps.paco.Experiment.java

License:Open Source License

@JsonIgnore
public DateTime getStartDateTime() {
    DateTime firstTime = null;/*  www. j  a  v  a2  s  .  c o  m*/
    for (SignalingMechanism signalingMechanism : getSignalingMechanisms()) {
        DateTime firstTimeForSignalGroup = null;
        if (signalingMechanism instanceof SignalSchedule) {
            SignalSchedule schedule = (SignalSchedule) signalingMechanism;
            if (schedule.getScheduleType().equals(SignalSchedule.WEEKDAY)) {
                List<SignalTime> times = schedule.getSignalTimes();
                DateTime firstTimeForDay = new DateTime().plus(times.get(0).getFixedTimeMillisFromMidnight());
                firstTimeForSignalGroup = new DateMidnight(TimeUtil.unformatDate(getStartDate())).toDateTime()
                        .withMillisOfDay(firstTimeForDay.getMillisOfDay());
            } else {
                firstTimeForSignalGroup = new DateMidnight(TimeUtil.unformatDate(getStartDate())).toDateTime();
            }
        } else {
            firstTimeForSignalGroup = new DateMidnight(TimeUtil.unformatDate(getStartDate())).toDateTime();
        }
        if (firstTime == null || firstTimeForSignalGroup.isBefore(firstTime)) {
            firstTime = firstTimeForSignalGroup;
        }
    }
    return firstTime;
}