Example usage for org.joda.time MutableDateTime setMinuteOfHour

List of usage examples for org.joda.time MutableDateTime setMinuteOfHour

Introduction

In this page you can find the example usage for org.joda.time MutableDateTime setMinuteOfHour.

Prototype

public void setMinuteOfHour(final int minuteOfHour) 

Source Link

Document

Set the minute of the hour to the specified value.

Usage

From source file:ch.windmobile.server.mongo.MongoDataSource.java

License:Open Source License

static protected DateTime getExpirationDate(DateTime now, DateTime lastUpdate) {
    MutableDateTime expirationDate = new MutableDateTime(lastUpdate.getZone());

    if (isSummerFrequency(now)) {
        expirationDate.setMillis(lastUpdate.getMillis() + 20 * 60 * 1000);
        if (expirationDate.getHourOfDay() >= 20) {
            expirationDate.addDays(1);/*from w w w . j  a  v a2s  .  co m*/
            expirationDate.setHourOfDay(8);
            expirationDate.setMinuteOfHour(0);
            expirationDate.setSecondOfMinute(0);
        }
    } else {
        expirationDate.setMillis(lastUpdate.getMillis() + 60 * 60 * 1000);
        if (expirationDate.getHourOfDay() >= 17) {
            expirationDate.addDays(1);
            expirationDate.setHourOfDay(9);
            expirationDate.setMinuteOfHour(0);
            expirationDate.setSecondOfMinute(0);
        }
    }
    return expirationDate.toDateTime();
}

From source file:com.carmatech.cassandra.ShardingFrequency.java

License:Apache License

public static long calculateBucket(final long timestamp, final ShardingFrequency frequency) {
    final MutableDateTime dateTime = new MutableDateTime(timestamp);

    if (frequency.compareTo(SECONDLY) >= 0)
        dateTime.setMillisOfSecond(0);/* w w  w .j a  va 2s  .  c  o  m*/
    if (frequency.compareTo(MINUTELY) >= 0)
        dateTime.setSecondOfMinute(0);
    if (frequency.compareTo(HOURLY) >= 0)
        dateTime.setMinuteOfHour(0);
    if (frequency.compareTo(DAILY) >= 0)
        dateTime.setHourOfDay(0);
    if (frequency.compareTo(WEEKLY) >= 0)
        dateTime.setDayOfWeek(1);
    if (frequency.compareTo(MONTHLY) >= 0)
        dateTime.setDayOfMonth(1);

    return dateTime.getMillis();
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToHour(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);//from w w  w  . j a v  a 2s  .c om
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToDay(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);// ww w.  ja  v  a  2s.  co  m
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToMonth(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);/*www .  j  a  va  2s  .  c  om*/
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    result.setDayOfMonth(1);
    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToWeek(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);/*  w  ww  . jav  a  2s .c  om*/
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    result.setHourOfDay(0);

    if (time.getDayOfWeek() != 7) {
        result.setDayOfWeek(1);
        result.add(Days.ONE.multipliedBy(-1));
    }

    return new DateTime(result);
}

From source file:com.ning.metrics.serialization.util.DateTimeUtil.java

License:Apache License

public DateTime truncateToYear(ReadableDateTime time) {
    MutableDateTime result = new MutableDateTime(time);
    result.setMillisOfSecond(0);//  w ww.ja v  a  2 s  . c  om
    result.setSecondOfMinute(0);
    result.setMinuteOfHour(0);
    result.setHourOfDay(0);
    result.setDayOfMonth(1);
    result.setMonthOfYear(1);
    return new DateTime(result);
}

From source file:com.soen.hasslefree.beans.PhysicianAvailabilityBean.java

public String addAvailability() {
    String[] startSplit = startTimeHolder.split(":");
    String[] endSplit = endTimeHolder.split(":");
    MutableDateTime startDateTime = new MutableDateTime(dateHolder);
    MutableDateTime endDateTime = new MutableDateTime(dateHolder);
    String patientEmail = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
            .get("patientEmail");

    // Setting start time value from string input
    startDateTime.setHourOfDay(Integer.parseInt(startSplit[0]));
    startDateTime.setMinuteOfHour(Integer.parseInt(startSplit[1]));

    // Setting end time value from string input
    endDateTime.setHourOfDay(Integer.parseInt(endSplit[0]));
    endDateTime.setMinuteOfHour(Integer.parseInt(endSplit[1]));

    PhysicianAvailability pa = new PhysicianAvailability();
    pa.setStartTime(startDateTime.toDateTime());
    pa.setEndTime(endDateTime.toDateTime());
    pa.setRelatedPhysician(Physician.getPhysicianByEmail(patientEmail));
    pa.savePhysicianAvailability();//  w ww .  j av  a2s .co  m

    return "myAvailabilities";
}

From source file:com.tmathmeyer.sentinel.ui.tabs.AddCommitmentDisplay.java

License:Open Source License

/**
 * Sets the default date and time text fields to the current date and time
 * //from w ww  . j a  v  a 2s. co m
 * Should be only called if creating a new commitment, not when editing
 * since edit event already has a date and time to fill the text fields with
 */
public void setCurrentDateAndTime() {
    this.startTimeDatePicker.setDate(selectedTime);
    MutableDateTime mdt = DateTime.now().toMutableDateTime();
    int quarterHours = mdt.getMinuteOfHour() / 15;
    int minutes = quarterHours < 4 ? (quarterHours + 1) * 15 : (quarterHours) * 15;
    if (minutes == 60) {
        mdt.addHours(1);
        mdt.setMinuteOfHour(0);
    } else
        mdt.setMinuteOfHour(minutes);
    this.startTimeDatePicker.setTime(mdt.toDateTime());
}

From source file:com.tmathmeyer.sentinel.ui.tabs.AddEventDisplay.java

License:Open Source License

/**
 * Sets the default date and time text fields to the current date and time
 * /* w  w  w  . java  2 s. c  om*/
 * Should be only called if creating a new event, not when editing since
 * edit event already has a date and time to fill the text fields with
 */
public void setCurrentDateAndTime() {
    this.startTimeDatePicker.setDate(selectedTime);
    this.endTimeDatePicker.setDate(selectedTime);

    MutableDateTime mdt = DateTime.now().toMutableDateTime();
    int quarterHours = mdt.getMinuteOfHour() / 15;
    int minutes = quarterHours < 4 ? (quarterHours + 1) * 15 : (quarterHours) * 15;
    if (minutes == 60) {
        mdt.addHours(1);
        mdt.setMinuteOfHour(0);
    } else
        mdt.setMinuteOfHour(minutes);

    this.startTimeDatePicker.setTime(mdt.toDateTime());
    mdt.addHours(1);
    this.endTimeDatePicker.setTime(mdt.toDateTime());
}