Example usage for org.joda.time DateTime getMinuteOfHour

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

Introduction

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

Prototype

public int getMinuteOfHour() 

Source Link

Document

Get the minute of hour field value.

Usage

From source file:nu.yona.app.ui.message.AdminNotificationFragment.java

private String getTime(String date) {
    String pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
    DateTimeFormatter dtf = DateTimeFormat.forPattern(pattern);
    DateTime dateTime = dtf.parseDateTime(date);
    return dateTime.getHourOfDay() + ":" + dateTime.getMinuteOfHour();
}

From source file:op.care.dfn.PnlDFN.java

License:Open Source License

private java.util.List<Component> addCommands() {

    java.util.List<Component> list = new ArrayList<Component>();

    /***//w ww  . j  a v  a 2  s.c om
     *      _     _            _       _     _
     *     | |__ | |_ _ __    / \   __| | __| |
     *     | '_ \| __| '_ \  / _ \ / _` |/ _` |
     *     | |_) | |_| | | |/ ___ \ (_| | (_| |
     *     |_.__/ \__|_| |_/_/   \_\__,_|\__,_|
     *
     */
    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {

        final JideButton btnAdd = GUITools.createHyperlinkButton(SYSTools.xx("nursingrecords.dfn.btnadd"),
                SYSConst.icon22add, null);
        btnAdd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if (!resident.isActive()) {
                    OPDE.getDisplayManager()
                            .addSubMessage(new DisplayMessage("misc.msg.cantChangeInactiveResident"));
                    return;
                }

                final JidePopup popup = new JidePopup();
                popup.setMovable(false);
                PnlSelectIntervention pnl = new PnlSelectIntervention(new Closure() {
                    @Override
                    public void execute(Object o) {
                        popup.hidePopup();
                        if (o != null) {
                            Object[] objects = (Object[]) o;
                            EntityManager em = OPDE.createEM();
                            try {
                                em.getTransaction().begin();
                                em.lock(em.merge(resident), LockModeType.OPTIMISTIC);

                                for (Object obj : objects) {
                                    Intervention intervention = em.merge((Intervention) obj);
                                    DFN dfn = em.merge(new DFN(resident, intervention));

                                    // Set Target and Actual according to the setting of JDCDate
                                    DateTime now = new DateTime();
                                    DateMidnight onDemandPIT = new DateMidnight(jdcDate.getDate());
                                    DateTime newDateTime = onDemandPIT.toDateTime()
                                            .plusHours(now.getHourOfDay()).plusMinutes(now.getMinuteOfHour())
                                            .plusSeconds(now.getSecondOfMinute());
                                    dfn.setSoll(newDateTime.toDate());
                                    dfn.setIst(newDateTime.toDate());

                                    CollapsiblePane cp1 = createCP4(dfn);
                                    synchronized (mapDFN2Pane) {
                                        mapDFN2Pane.put(dfn, cp1);
                                    }
                                    synchronized (mapShift2DFN) {
                                        mapShift2DFN.get(dfn.getShift()).add(dfn);
                                    }
                                }

                                em.getTransaction().commit();

                                CollapsiblePane cp2 = createCP4(DFNTools.SHIFT_ON_DEMAND);
                                synchronized (mapShift2Pane) {
                                    mapShift2Pane.put(DFNTools.SHIFT_ON_DEMAND, cp2);
                                }
                                buildPanel(false);
                                try {
                                    synchronized (mapShift2Pane) {
                                        mapShift2Pane.get(DFNTools.SHIFT_ON_DEMAND).setCollapsed(false);
                                    }
                                } catch (PropertyVetoException e) {
                                    OPDE.debug(e);
                                }

                            } catch (OptimisticLockException ole) {
                                OPDE.warn(ole);
                                if (em.getTransaction().isActive()) {
                                    em.getTransaction().rollback();
                                }
                                if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                    OPDE.getMainframe().emptyFrame();
                                    OPDE.getMainframe().afterLogin();
                                }
                                OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                            } catch (Exception e) {
                                if (em.getTransaction().isActive()) {
                                    em.getTransaction().rollback();
                                }
                                OPDE.fatal(e);
                            } finally {
                                em.close();
                            }
                        }
                    }
                });
                popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
                popup.getContentPane().add(pnl);
                popup.setOwner(btnAdd);
                popup.removeExcludedComponent(pnl);
                popup.setDefaultFocusComponent(pnl);
                GUITools.showPopup(popup, SwingConstants.NORTH);
            }
        });
        list.add(btnAdd);

    }

    final JideButton printPrescription = GUITools.createHyperlinkButton("nursingrecords.dfn.print",
            SYSConst.icon22print2, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {

                    String html = "";

                    synchronized (mapShift2DFN) {
                        html += "<h1 id=\"fonth1\" >" + ResidentTools.getFullName(resident) + "</h1>";
                        html += SYSConst.html_h2(SYSTools.xx("nursingrecords.bhp") + ": "
                                + SYSConst.html_bold(DateFormat.getDateInstance().format(jdcDate.getDate())));

                        for (Byte shift : new Byte[] { DFNTools.SHIFT_ON_DEMAND, DFNTools.SHIFT_VERY_EARLY,
                                DFNTools.SHIFT_EARLY, DFNTools.SHIFT_LATE, DFNTools.SHIFT_VERY_LATE }) {
                            html += DFNTools.getDFNsAsHTMLtable(mapShift2DFN.get(shift));
                        }
                    }

                    SYSFilesTools.print(html, true);
                }
            });
    list.add(printPrescription);
    return list;
}

From source file:op.tools.SYSCalendar.java

License:Open Source License

/**
 * determines to which timeofday code a given date object belongs. The settings in SYSProps are taken into account.
 * or in short: it answers a question like "is 0800h early, noon or early in the morning ?"
 *
 * @param date/*from  w  ww.j  a  v a 2s. c  om*/
 * @return timecode
 */
public static byte whatTimeIDIs(Date date) {
    byte timeid;

    DateTimeFormatter parser = DateTimeFormat.forPattern("HH:mm");

    DateTime early_in_the_morning = parser
            .parseDateTime(OPDE.getProps().getProperty(DFNTools.STRING_EARLY_IN_THE_MORNING));
    DateTime morning = parser.parseDateTime(OPDE.getProps().getProperty(DFNTools.STRING_MORNING));
    DateTime noon = parser.parseDateTime(OPDE.getProps().getProperty(DFNTools.STRING_NOON));
    DateTime afternoon = parser.parseDateTime(OPDE.getProps().getProperty(DFNTools.STRING_AFTERNOON));
    DateTime evening = parser.parseDateTime(OPDE.getProps().getProperty(DFNTools.STRING_EVENING));
    DateTime late_at_night = parser.parseDateTime(OPDE.getProps().getProperty(DFNTools.STRING_LATE_AT_NIGHT));

    Period period_early_in_the_morning = new Period(early_in_the_morning.getHourOfDay(),
            early_in_the_morning.getMinuteOfHour(), early_in_the_morning.getSecondOfMinute(),
            early_in_the_morning.getMillisOfSecond());
    Period period_morning = new Period(morning.getHourOfDay(), morning.getMinuteOfHour(),
            morning.getSecondOfMinute(), morning.getMillisOfSecond());
    Period period_noon = new Period(noon.getHourOfDay(), noon.getMinuteOfHour(), noon.getSecondOfMinute(),
            noon.getMillisOfSecond());
    Period period_afternoon = new Period(afternoon.getHourOfDay(), afternoon.getMinuteOfHour(),
            afternoon.getSecondOfMinute(), afternoon.getMillisOfSecond());
    Period period_evening = new Period(evening.getHourOfDay(), evening.getMinuteOfHour(),
            evening.getSecondOfMinute(), evening.getMillisOfSecond());
    Period period_late_at_night = new Period(late_at_night.getHourOfDay(), late_at_night.getMinuteOfHour(),
            late_at_night.getSecondOfMinute(), late_at_night.getMillisOfSecond());

    DateTime ref = new DateTime(date);
    DateTime eitm = new DateMidnight(date).toDateTime().plus(period_early_in_the_morning);
    DateTime m = new DateMidnight(date).toDateTime().plus(period_morning);
    DateTime n = new DateMidnight(date).toDateTime().plus(period_noon);
    DateTime a = new DateMidnight(date).toDateTime().plus(period_afternoon);
    DateTime e = new DateMidnight(date).toDateTime().plus(period_evening);
    DateTime lan = new DateMidnight(date).toDateTime().plus(period_late_at_night);

    if (eitm.compareTo(ref) <= 0 && ref.compareTo(m) < 0) {
        timeid = DFNTools.BYTE_EARLY_IN_THE_MORNING;
    } else if (m.compareTo(ref) <= 0 && ref.compareTo(n) < 0) {
        timeid = DFNTools.BYTE_MORNING;
    } else if (n.compareTo(ref) <= 0 && ref.compareTo(a) < 0) {
        timeid = DFNTools.BYTE_NOON;
    } else if (a.compareTo(ref) <= 0 && ref.compareTo(e) < 0) {
        timeid = DFNTools.BYTE_AFTERNOON;
    } else if (e.compareTo(ref) <= 0 && ref.compareTo(lan) < 0) {
        timeid = DFNTools.BYTE_EVENING;
    } else {
        timeid = DFNTools.BYTE_LATE_AT_NIGHT;
    }
    return timeid;
}

From source file:org.adl.datamodels.datatypes.DateTimeValidatorImpl.java

/**
 * Compares two valid data model elements for equality.
 * // w  w w .  j a v  a2s  .  c  o  m
 * @param iFirst  The first value being compared.
 * 
 * @param iSecond The second value being compared.
 * 
 * @param iDelimiters The common set of delimiters associated with the
 * values being compared.
 * 
 * @return Returns <code>true</code> if the two values are equal, otherwise
 *         <code>false</code>.
 */
@Override
public boolean compare(String iFirst, String iSecond, List<DMDelimiter> iDelimiters) {

    boolean equal = true;

    DateTimeFormatter dtp = ISODateTimeFormat.dateTimeParser();

    try {
        // Parse the first string and remove the sub-seconds
        DateTime dt1 = dtp.parseDateTime(iFirst);
        dt1 = new DateTime(dt1.getYear(), dt1.getMonthOfYear(), dt1.getDayOfMonth(), dt1.getHourOfDay(),
                dt1.getMinuteOfHour(), dt1.getSecondOfMinute(), 0);

        // Parse the second string and remove the sub-seconds
        DateTime dt2 = dtp.parseDateTime(iSecond);
        dt2 = new DateTime(dt2.getYear(), dt2.getMonthOfYear(), dt2.getDayOfMonth(), dt2.getHourOfDay(),
                dt2.getMinuteOfHour(), dt2.getSecondOfMinute(), 0);

        equal = dt1.equals(dt2);
    } catch (Exception e) {
        // String format error -- these cannot be equal
        equal = false;
    }

    return equal;
}

From source file:org.aludratest.cloud.web.report.ResourceReportUtil.java

License:Apache License

private static JavaScriptObject createTimeEntry(DateTime time, int activeResources) {
    JavaScriptObject result = new JavaScriptObject();
    time = time.toDateTime(DateTimeZone.UTC);

    // convert time to JavaScript UTC time
    StringBuilder sbDateTime = new StringBuilder();
    sbDateTime.append("Date.UTC(");
    sbDateTime.append(time.getYear()).append(", ");
    sbDateTime.append(time.getMonthOfYear() - 1).append(", ");
    sbDateTime.append(time.getDayOfMonth()).append(", ");
    sbDateTime.append(time.getHourOfDay()).append(", ");
    sbDateTime.append(time.getMinuteOfHour()).append(", ");
    sbDateTime.append(time.getSecondOfMinute()).append(", ");
    sbDateTime.append(time.getMillisOfSecond()).append(")");

    result.set("x", new JavaScriptCodeFragment(sbDateTime.toString()));
    result.set("y", new JavaScriptCodeFragment("" + activeResources));

    return result;
}

From source file:org.apache.beam.sdk.io.jdbc.JdbcUtil.java

License:Apache License

private static Calendar getDateOrTimeOnly(DateTime dateTime, boolean wantDateOnly) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone(dateTime.getZone().getID()));

    if (wantDateOnly) { // return date only
        cal.set(Calendar.YEAR, dateTime.getYear());
        cal.set(Calendar.MONTH, dateTime.getMonthOfYear() - 1);
        cal.set(Calendar.DATE, dateTime.getDayOfMonth());

        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
    } else { // return time only
        cal.set(Calendar.YEAR, 1970);
        cal.set(Calendar.MONTH, Calendar.JANUARY);
        cal.set(Calendar.DATE, 1);

        cal.set(Calendar.HOUR_OF_DAY, dateTime.getHourOfDay());
        cal.set(Calendar.MINUTE, dateTime.getMinuteOfHour());
        cal.set(Calendar.SECOND, dateTime.getSecondOfMinute());
        cal.set(Calendar.MILLISECOND, dateTime.getMillisOfSecond());
    }// ww  w .j  a va2s  . c  om

    return cal;
}

From source file:org.apache.falcon.regression.core.util.TimeUtil.java

License:Apache License

public static String get20roundedTime(String oozieBaseTime) {
    DateTime startTime = new DateTime(oozieDateToDate(oozieBaseTime), DateTimeZone.UTC);
    if (startTime.getMinuteOfHour() < 20) {
        startTime = startTime.minusMinutes(startTime.getMinuteOfHour());
    } else if (startTime.getMinuteOfHour() < 40) {
        startTime = startTime.minusMinutes(startTime.getMinuteOfHour() + 20);
    } else {//from  w  w  w . j a  va 2s  .co m
        startTime = startTime.minusMinutes(startTime.getMinuteOfHour() + 40);
    }
    return dateToOozieDate(startTime.toDate());
}

From source file:org.apache.isis.applib.value.Time.java

License:Apache License

/**
 * Create a Time object for storing a time with the time set to the
 * specified time of the Joda Time DateTime object.
 *//*from w  ww  .ja  v a  2s  .  c  o  m*/
public Time(final DateTime dateTime) {
    this.time = newDateTime(dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute());
}

From source file:org.apache.pig.pen.AugmentBaseDataVisitor.java

License:Apache License

Object GetSmallerValue(Object v) {
    byte type = DataType.findType(v);

    if (type == DataType.BAG || type == DataType.TUPLE || type == DataType.MAP)
        return null;

    switch (type) {
    case DataType.CHARARRAY:
        String str = (String) v;
        if (str.length() > 0)
            return str.substring(0, str.length() - 1);
        else// ww  w. j a v a  2  s .  c om
            return null;
    case DataType.BYTEARRAY:
        DataByteArray data = (DataByteArray) v;
        if (data.size() > 0)
            return new DataByteArray(data.get(), 0, data.size() - 1);
        else
            return null;
    case DataType.INTEGER:
        return Integer.valueOf((Integer) v - 1);
    case DataType.LONG:
        return Long.valueOf((Long) v - 1);
    case DataType.FLOAT:
        return Float.valueOf((Float) v - 1);
    case DataType.DOUBLE:
        return Double.valueOf((Double) v - 1);
    case DataType.BIGINTEGER:
        return ((BigInteger) v).subtract(BigInteger.ONE);
    case DataType.BIGDECIMAL:
        return ((BigDecimal) v).subtract(BigDecimal.ONE);
    case DataType.DATETIME:
        DateTime dt = (DateTime) v;
        if (dt.getMillisOfSecond() != 0) {
            return dt.minusMillis(1);
        } else if (dt.getSecondOfMinute() != 0) {
            return dt.minusSeconds(1);
        } else if (dt.getMinuteOfHour() != 0) {
            return dt.minusMinutes(1);
        } else if (dt.getHourOfDay() != 0) {
            return dt.minusHours(1);
        } else {
            return dt.minusDays(1);
        }
    default:
        return null;
    }

}

From source file:org.apache.pig.pen.AugmentBaseDataVisitor.java

License:Apache License

Object GetLargerValue(Object v) {
    byte type = DataType.findType(v);

    if (type == DataType.BAG || type == DataType.TUPLE || type == DataType.MAP)
        return null;

    switch (type) {
    case DataType.CHARARRAY:
        return (String) v + "0";
    case DataType.BYTEARRAY:
        String str = ((DataByteArray) v).toString();
        str = str + "0";
        return new DataByteArray(str);
    case DataType.INTEGER:
        return Integer.valueOf((Integer) v + 1);
    case DataType.LONG:
        return Long.valueOf((Long) v + 1);
    case DataType.FLOAT:
        return Float.valueOf((Float) v + 1);
    case DataType.DOUBLE:
        return Double.valueOf((Double) v + 1);
    case DataType.BIGINTEGER:
        return ((BigInteger) v).add(BigInteger.ONE);
    case DataType.BIGDECIMAL:
        return ((BigDecimal) v).add(BigDecimal.ONE);
    case DataType.DATETIME:
        DateTime dt = (DateTime) v;
        if (dt.getMillisOfSecond() != 0) {
            return dt.plusMillis(1);
        } else if (dt.getSecondOfMinute() != 0) {
            return dt.plusSeconds(1);
        } else if (dt.getMinuteOfHour() != 0) {
            return dt.plusMinutes(1);
        } else if (dt.getHourOfDay() != 0) {
            return dt.plusHours(1);
        } else {/*from  w ww .jav a  2 s  .co  m*/
            return dt.plusDays(1);
        }
    default:
        return null;
    }
}