Example usage for org.joda.time DateTime getMinuteOfDay

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

Introduction

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

Prototype

public int getMinuteOfDay() 

Source Link

Document

Get the minute of day field value.

Usage

From source file:com.chiorichan.dvr.storage.Interface.java

License:Mozilla Public License

public long getTen(DateTime td) {
    // Calculate the rounded ten minutes.
    double lastTen = Math.floor(td.getMinuteOfDay() / 10);

    return Math.round(lastTen);
}

From source file:com.inspireVeiN.iPlayed.iPlayedPlayerListener.java

License:Open Source License

private void login(Player p) {
    String player = p.getName();//from   ww  w .  j  a v a  2s . c  o m
    Arguments entry = null;
    if (plugin.timesdb.hasIndex(player))
        entry = plugin.timesdb.getArguments(player);
    else {
        entry = new Arguments(player);
        entry.setValue("playtime", "0");
        plugin.timesdb.addIndex(player, entry);
        plugin.timesdb.update();
    }
    DateTime dt = new DateTime();
    plugin.timesdb.setArgument(player, "lastlogin",
            dt.getMonthOfYear() + "/" + dt.getDayOfMonth() + "/" + dt.getYear(), true);
    plugin.timesdb.setArgument(player, "startTime", Integer.toString(dt.getMinuteOfDay()), true);
}

From source file:com.inspireVeiN.iPlayed.iPlayedPlayerListener.java

License:Open Source License

private void logout(Player p) {
    String player = p.getName();//from   ww  w.ja v  a  2 s. c  o  m
    Arguments entry = plugin.timesdb.getArguments(player);
    DateTime dt = new DateTime();
    int startTime = entry.getInteger("startTime");
    int endTime = dt.getMinuteOfDay();
    int playtime = entry.getInteger("playtime");
    if (endTime <= startTime)
        playtime += 1440 - startTime + endTime;
    else
        playtime += endTime - startTime;
    plugin.timesdb.setArgument(player, "playtime", playtime, true);
    plugin.timesdb.setArgument(player, "startTime", "0", true);
}

From source file:com.inspireVeiN.iPlayed.iPlayedPlayerListener.java

License:Open Source License

private void resetStartTime(Player p) {
    String player = p.getName();/*ww  w.j a v  a 2s . c om*/
    DateTime dt = new DateTime();
    plugin.timesdb.setArgument(player, "startTime", Integer.toString(dt.getMinuteOfDay()), true);
}

From source file:com.marand.thinkmed.medications.business.impl.MedicationsEhrUtils.java

License:Open Source License

public static boolean isRoundsTimeForSession(final DateTime when, final RoundsIntervalDto roundsInterval) {
    final int minuteOfDay = when.getMinuteOfDay();

    final int roundsStart = roundsInterval.getStartHour() * 60 + roundsInterval.getStartMinute();
    final int roundsEnd = roundsInterval.getEndHour() * 60 + roundsInterval.getEndMinute();

    return minuteOfDay > roundsStart && minuteOfDay < roundsEnd;
}

From source file:com.pandits.opensource.JodaTimeUtil.java

License:Open Source License

public int getMinuteOfTheDay(long timeInMillis, TimeZone timeZone) {
    DateTime dateTime = createDateTime(timeInMillis, timeZone);
    return dateTime.getMinuteOfDay();
}

From source file:dk.teachus.frontend.pages.periods.PeriodPage.java

License:Apache License

public PeriodPage(final Period period) {
    super(UserLevel.TEACHER, true);

    add(new Label("editPeriodTitle", TeachUsSession.get().getString("PeriodPage.editForm"))); //$NON-NLS-1$ //$NON-NLS-2$

    final FormPanel form = new FormPanel("form"); //$NON-NLS-1$
    add(form);/*from w  w  w  .jav  a 2s.  co m*/

    // Name
    final StringTextFieldElement nameElement = new StringTextFieldElement(
            TeachUsSession.get().getString("General.name"), new PropertyModel<String>(period, "name"), true); //$NON-NLS-1$ //$NON-NLS-2$
    nameElement.add(StringValidator.maximumLength(100));
    nameElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(nameElement);

    // Begin date
    final DateElement beginDateElement = new DateElement(TeachUsSession.get().getString("General.startDate"), //$NON-NLS-1$
            new PropertyModel<DateMidnight>(period, "beginDate")); //$NON-NLS-1$
    beginDateElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(beginDateElement);

    // End date
    final DateElement endDateElement = new DateElement(TeachUsSession.get().getString("General.endDate"), //$NON-NLS-1$
            new PropertyModel<DateMidnight>(period, "endDate")); //$NON-NLS-1$
    endDateElement.add(new IValidator<DateMidnight>() {
        private static final long serialVersionUID = 1L;

        public void validate(IValidatable<DateMidnight> validatable) {
            DateMidnight date = validatable.getValue();
            if (date != null) {
                // Check if the end date conflicts with some bookings
                if (period.getId() != null) {
                    BookingDAO bookingDAO = TeachUsApplication.get().getBookingDAO();
                    DateTime lastBookingDate = bookingDAO.getLastBookingDate(period);
                    if (lastBookingDate != null) {
                        if (date.isBefore(lastBookingDate)) {
                            ValidationError validationError = new ValidationError();
                            String bookingConflictMessage = TeachUsSession.get()
                                    .getString("PeriodPage.endDateBookingConflict");
                            bookingConflictMessage = bookingConflictMessage.replace("${lastBookingDate}",
                                    Formatters.getFormatPrettyDate().print(lastBookingDate));
                            validationError.setMessage(bookingConflictMessage); //$NON-NLS-1$
                            validatable.error(validationError);
                        }
                    }
                }
            }
        }
    });
    form.addElement(endDateElement);

    // Time elements
    final List<Integer> hours = new ArrayList<Integer>();
    DateTime dt = new DateTime().withTime(0, 0, 0, 0);
    final int day = dt.getDayOfMonth();
    while (day == dt.getDayOfMonth()) {
        hours.add(dt.getMinuteOfDay());
        dt = dt.plusMinutes(30);
    }

    final TimeChoiceRenderer<Integer> timeChoiceRenderer = new TimeChoiceRenderer<Integer>();

    // Start time
    final DropDownElement<Integer> startTimeElement = new DropDownElement<Integer>(
            TeachUsSession.get().getString("General.startTime"), new TimeModel(new PropertyModel<LocalTime>( //$NON-NLS-1$
                    period, "startTime")), //$NON-NLS-1$
            hours, timeChoiceRenderer, true);
    startTimeElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(startTimeElement);

    // End time
    final DropDownElement<Integer> endTimeElement = new DropDownElement<Integer>(
            TeachUsSession.get().getString("General.endTime"), //$NON-NLS-1$
            new TimeModel(new PropertyModel<LocalTime>(period, "endTime")),
            hours, timeChoiceRenderer, true);
    endTimeElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(endTimeElement);

    // Location
    final StringTextFieldElement locationElement = new StringTextFieldElement(
            TeachUsSession.get().getString("General.location"), new PropertyModel<String>(period, "location")); //$NON-NLS-1$ //$NON-NLS-2$
    locationElement.add(StringValidator.maximumLength(100));
    locationElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(locationElement);

    // Price
    final DecimalFieldElement priceElement = new DecimalFieldElement(
            TeachUsSession.get().getString("General.price"), new PropertyModel<Double>(period, "price"), 6); //$NON-NLS-1$ //$NON-NLS-2$
    priceElement.setReadOnly(period.getStatus() != Status.DRAFT);
    priceElement.setDefaultNullValue(0.0);
    form.addElement(priceElement);

    // Lesson duration
    final IntegerFieldElement lessonDurationElement = new IntegerFieldElement(
            TeachUsSession.get().getString("General.lessonDuration"), new PropertyModel<Integer>( //$NON-NLS-1$
                    period, "lessonDuration"), //$NON-NLS-1$
            true, 4);
    lessonDurationElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(lessonDurationElement);

    // Interval Between Lesson Start
    final IntegerFieldElement intervalBetweenLessonStartElement = new IntegerFieldElement(
            TeachUsSession.get().getString("General.intervalBetweenLessonStart"), //$NON-NLS-1$
            new PropertyModel<Integer>(period, "intervalBetweenLessonStart"), true, 4); //$NON-NLS-1$
    intervalBetweenLessonStartElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(intervalBetweenLessonStartElement);

    // Week days
    final CheckGroupElement<WeekDay> weekDaysElement = new CheckGroupElement<WeekDay>(
            TeachUsSession.get().getString("General.weekDays"), new PropertyModel<List<WeekDay>>(period, //$NON-NLS-1$
                    "weekDays"), //$NON-NLS-1$
            Arrays.asList(WeekDay.values()), new WeekDayChoiceRenderer(Format.LONG), true);
    weekDaysElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(weekDaysElement);

    // Repeat every week
    final IntegerFieldElement repeatEveryWeekElement = new IntegerFieldElement(
            TeachUsSession.get().getString("General.repeatEveryWeek"), //$NON-NLS-1$
            new PropertyModel<Integer>(period, "repeatEveryWeek")); //$NON-NLS-1$
    repeatEveryWeekElement.setReadOnly(period.getStatus() != Status.DRAFT);
    //      repeatEveryWeekElement.setDefaultNullValue(1);
    form.addElement(repeatEveryWeekElement);

    // Status
    final List<Status> statusList = Arrays.asList(Status.values());
    final DropDownElement<Status> statusElement = new DropDownElement<Status>(
            TeachUsSession.get().getString("General.status"), new PropertyModel<Status>(period, "status"), //$NON-NLS-1$//$NON-NLS-2$
            statusList, new PeriodStatusRenderer());
    statusElement.setReadOnly(period.getStatus() != Status.DRAFT);
    form.addElement(statusElement);

    // Buttons
    form.addElement(new ButtonPanelElement() {
        private static final long serialVersionUID = 1L;

        @Override
        protected List<IButton> getAdditionalButtons() {
            final List<IButton> buttons = new ArrayList<IButton>();
            buttons.add(new IButton() {
                private static final long serialVersionUID = 1L;

                public String getValue() {
                    return TeachUsSession.get().getString("General.preview"); //$NON-NLS-1$
                }

                public void onClick(final AjaxRequestTarget target) {
                    final WebMarkupContainer preview = generatePreview(period);
                    PeriodPage.this.replace(preview);
                    target.add(preview);
                }
            });
            return buttons;
        }

        @Override
        protected void onCancel() {
            getRequestCycle().setResponsePage(PeriodsPage.class);
        }

        @Override
        protected void onSave(final AjaxRequestTarget target) {
            final PeriodDAO periodDAO = TeachUsApplication.get().getPeriodDAO();

            periodDAO.save(period);

            getRequestCycle().setResponsePage(PeriodsPage.class);
        }
    });

    add(new Label("previewTitle", TeachUsSession.get().getString("General.preview"))); //$NON-NLS-1$ //$NON-NLS-2$

    if (period.getId() != null) {
        add(generatePreview(period));
    } else {
        add(new WebComponent("calendar").setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true)
                .setVisible(false));
    }
}

From source file:edu.htw.magw.dreamcatcher.DreamcatcherWebApplication.java

License:Apache License

@SuppressWarnings("unchecked")
private void createExampleData() {
    List<String> keyList = new ArrayList<String>(
            Arrays.asList(new String[] { "low alpha", "theta", "heigh gamma", "strength", "heigh alpha",
                    "delta", "low beta", "meditation", "heigh beta", "low gamma", "attention" }));

    JSONArray list = new JSONArray();

    Map<String, String> obj = null;
    Map<String, String> lastObj = null;

    DateTime startDateTime = new DateTime(2012, 1, 1, 22, 0);

    for (int i = 0; i < 1000; i++) {
        obj = new LinkedHashMap<String, String>();

        obj.put("timestamp", String.valueOf(startDateTime.getMinuteOfDay() + (i * 10)));

        for (String key : keyList) {
            if (lastObj != null) {
                if (lastObj.get(key) == null)
                    obj.put(key, String.valueOf(Math.random() * (15000 - 1) + 1));
                else
                    obj.put(key, String
                            .valueOf(Double.parseDouble(lastObj.get(key)) + Math.random() * (200 - 1) - 100));
            }/*w  w  w.  j av a  2 s  . c  om*/
        }

        lastObj = obj;
        list.add(obj);
    }

    System.out.println(list.toJSONString());
}

From source file:fi.aluesarjat.prototype.Reloader.java

License:Apache License

private void addJob(int hours, int minutes, Runnable runnable) {
    DateTime dateTime = new DateTime();
    long minutesOfDay = dateTime.getMinuteOfDay();
    long scheduleTime = hours * 60 + minutes;
    long initialDelay;
    if (minutesOfDay < scheduleTime) {
        initialDelay = scheduleTime - minutesOfDay;
    } else {/*from w  w w  .  j a  v a  2 s .  c o m*/
        initialDelay = 24 * 60 - minutesOfDay + scheduleTime;
    }
    System.err.println(initialDelay);
    scheduler.scheduleAtFixedRate(runnable, initialDelay, 24 * 60, TimeUnit.MINUTES);
}

From source file:Implement.DAO.BookingDAOImpl.java

@Override
public void insertOfflineBooking(int providerID, int days, int hours, int minutes, long bookingTime,
        long tripTime, String dateStr, String timeStr, String customerName, String customerPhone, String email,
        List<OfflineResourceDTO> offlineResources, int smallestInterval, long resourceTime) {
    DateTimeFormatter fmtDate = DateTimeFormat.forPattern("MM/dd/YYYY");
    DateTimeFormatter fmtTime = DateTimeFormat.forPattern("HH:mm");

    //  construct dynamic sql for used resources
    DateTimeFormatter formatterDateAndHour = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm:ss");
    String travelTimeStr = dateStr;
    if (days == 0) {
        travelTimeStr += " " + timeStr + ":00";
    } else {/*  w w w .j  a  v a2s . c o m*/
        travelTimeStr += " 00:00:00";
    }

    // insert offline resources first
    int i = 0;
    OfflineResourceDTO offlineResource = offlineResources.get(i);
    int providerResurceID = offlineResource.getProviderResourceID();
    int resourceHours = offlineResource.getHours();
    int resourceMinutes = offlineResource.getMinutes();
    int resourceDays = offlineResource.getDays();
    int noUnits = offlineResource.getNoUnits();
    String offlineResourceValue = "VALUES ";
    offlineResourceValue += "(@offlineBookingIDVar, " + providerResurceID + "," + noUnits + "," + resourceHours
            + "," + resourceMinutes + "," + resourceDays + ")";

    String usedResourceValue = "VALUES ";
    DateTime travelTime = formatterDateAndHour.parseDateTime(travelTimeStr);
    DateTime endTime = new DateTime(travelTime);
    if (resourceDays > 0) {
        endTime = endTime.plusDays(resourceDays);
    } else {
        // change hours to minutes
        int duration = resourceHours * 60 + resourceMinutes;
        endTime = endTime.plusMinutes(duration);
    }

    // loop each 5 minutes
    DateTime eachTime = new DateTime(travelTime);
    String date = fmtDate.print(eachTime);
    String time = fmtTime.print(eachTime);
    int usedResouceMinutes = eachTime.getMinuteOfDay();

    DateTime usedResourceOnlyDate = formatterDateAndHour.parseDateTime(date + " 00:00:00");
    long usedResourceMil = usedResourceOnlyDate.getMillis();
    usedResourceValue += " (" + providerResurceID + "," + usedResourceMil + "," + usedResouceMinutes + ","
            + noUnits + ",'" + date + "','" + time + "',@bookingCodeVar,@offlineBookingIDVar)";

    eachTime = eachTime.plusMinutes(smallestInterval);
    while (eachTime.isBefore(endTime)) {
        date = fmtDate.print(eachTime);
        time = fmtTime.print(eachTime);

        usedResourceOnlyDate = formatterDateAndHour.parseDateTime(date + " 00:00:00");
        usedResourceMil = usedResourceOnlyDate.getMillis();
        usedResouceMinutes = eachTime.getMinuteOfDay();
        usedResourceValue += ",(" + providerResurceID + "," + usedResourceMil + "," + usedResouceMinutes + ","
                + noUnits + ",'" + date + "','" + time + "',@bookingCodeVar,@offlineBookingIDVar)";
        eachTime = eachTime.plusMinutes(smallestInterval);
    }

    i++;
    int resourceLength = offlineResources.size();
    for (; i < resourceLength; i++) {
        offlineResource = offlineResources.get(i);
        providerResurceID = offlineResource.getProviderResourceID();
        resourceHours = offlineResource.getHours();
        resourceMinutes = offlineResource.getMinutes();
        resourceDays = offlineResource.getDays();
        noUnits = offlineResource.getNoUnits();
        offlineResourceValue += ",(@offlineBookingIDVar, " + providerResurceID + "," + noUnits + ","
                + resourceHours + "," + resourceMinutes + "," + resourceDays + ")";

        travelTime = formatterDateAndHour.parseDateTime(travelTimeStr);
        endTime = new DateTime(travelTime);
        if (resourceDays > 0) {
            endTime = endTime.plusDays(resourceDays);
        } else {

            // change hours to minutes
            int duration = resourceHours * 60 + resourceMinutes;
            endTime = endTime.plusMinutes(duration);
        }

        // loop each 5 minutes
        eachTime = new DateTime(travelTime);
        date = fmtDate.print(eachTime);
        time = fmtTime.print(eachTime);

        usedResouceMinutes = eachTime.getMinuteOfDay();

        usedResourceOnlyDate = formatterDateAndHour.parseDateTime(date + " 00:00:00");
        usedResourceMil = usedResourceOnlyDate.getMillis();
        usedResourceValue += ",(" + providerResurceID + "," + usedResourceMil + "," + usedResouceMinutes + ","
                + noUnits + ",'" + date + "','" + time + "',@bookingCodeVar,@offlineBookingIDVar)";

        eachTime = eachTime.plusMinutes(smallestInterval);
        while (eachTime.isBefore(endTime)) {
            date = fmtDate.print(eachTime);
            time = fmtTime.print(eachTime);

            usedResourceOnlyDate = formatterDateAndHour.parseDateTime(date + " 00:00:00");
            usedResourceMil = usedResourceOnlyDate.getMillis();
            usedResouceMinutes = eachTime.getMinuteOfDay();
            usedResourceValue += ",(" + providerResurceID + "," + usedResourceMil + "," + usedResouceMinutes
                    + "," + noUnits + ",'" + date + "','" + time + "',@bookingCodeVar,@offlineBookingIDVar)";
            eachTime = eachTime.plusMinutes(smallestInterval);
        }
    }

    String resourceInsertingStmt = "INSERT INTO OfflineResource(OfflineBookingID, ProviderResourceID, NoUnits,"
            + "Hours, Minutes,Days) ";
    resourceInsertingStmt += offlineResourceValue;
    String resourceInsertingParmDefinition = "@offlineBookingIDVar INT";

    String usedResourceInsertingStmt = "INSERT INTO UsedProviderResource(ProviderResourceID, Date, Time, NoUsedResources,"
            + "DateStr,TimeStr,BookingCode,OfflineBookingID)";
    usedResourceInsertingStmt += usedResourceValue;
    String usedResourceInsertingParmDefinition = "@bookingCodeVar NVARCHAR(10)," + "@offlineBookingIDVar INT";

    simpleJdbcCall = new SimpleJdbcCall(dataSource).withProcedureName("InsertNewOfflineBooking");
    SqlParameterSource in = new MapSqlParameterSource().addValue("days", days).addValue("minutes", minutes)
            .addValue("hours", hours).addValue("bookingTime", bookingTime).addValue("tripTime", tripTime)
            .addValue("dateStr", dateStr).addValue("timeStr", timeStr).addValue("customerName", customerName)
            .addValue("customerPhone", customerPhone).addValue("customerPhone", customerPhone)
            .addValue("email", email).addValue("providerID", providerID)
            .addValue("ResourceInsertingStmt", resourceInsertingStmt)
            .addValue("ResourceInsertingParmDefinition", resourceInsertingParmDefinition)
            .addValue("UsedResourceInsertingStmt", usedResourceInsertingStmt)
            .addValue("UsedResourceInsertingParmDefinition", usedResourceInsertingParmDefinition);
    simpleJdbcCall.execute(in);
}