List of usage examples for org.joda.time Minutes minutesBetween
public static Minutes minutesBetween(ReadablePartial start, ReadablePartial end)
Minutes
representing the number of whole minutes between the two specified partial datetimes. From source file:com.maxl.java.amikodesk.AMiKoDesk.java
License:Open Source License
static void checkIfUpdateRequired(JMenuItem update_item) { // Get current date DateTime dT = new DateTime(); // Get stored date String updateTime = m_prefs.get("updateTime", dT.now().toString()); DateTime uT = new DateTime(updateTime); // Seconds diffSec = Seconds.secondsBetween(uT, dT); Minutes diffMin = Minutes.minutesBetween(uT, dT); // Do this only when the application is freshly installed int timeDiff = diffMin.getMinutes(); /*//from w w w .ja v a 2s . c om if (timeDiff == 0) m_prefs.put("updateTime", dT.now().toString()); */ // First check if everything needs to be updated... switch (m_prefs.getInt("update", 0)) { case 0: // Manual // do nothing break; case 1: // Daily if (timeDiff > 60 * 24) { m_full_db_update = true; update_item.doClick(); } break; case 2: // Weekly if (timeDiff > 60 * 24 * 7) { m_full_db_update = true; update_item.doClick(); } break; case 3: // Monthly if (timeDiff > 60 * 24 * 30) { m_full_db_update = true; update_item.doClick(); } break; default: break; } // else proceed with the Preisvergleich-only update switch (m_prefs.getInt("update-comp", 0)) { case 0: // Manual // do nothing break; case 1: // Half-hourly if (timeDiff % 30 == 0) { m_full_db_update = false; update_item.doClick(); } break; case 2: // Hourly if (timeDiff % 60 == 0) { m_full_db_update = false; update_item.doClick(); } break; case 3: // Half-daily if (timeDiff % (4 * 60) == 0) { m_full_db_update = false; update_item.doClick(); } break; default: break; } }
From source file:com.microsoft.hsg.android.simplexml.client.HealthVaultRestClient.java
License:Open Source License
public void tokenRefresh(Connection connection) { if (Minutes.minutesBetween(DateTime.now(), mLastRefreshedSessionCredential) .isGreaterThan(Minutes.minutes(mSessionCredentialCallThresholdMinutes))) { connection.getAuthenticator().authenticate(connection, true); mLastRefreshedSessionCredential = DateTime.now(); mSettings.setSessionExpiration(); }/* w w w . j ava2 s.c o m*/ }
From source file:com.pearson.eidetic.driver.threads.EideticSubThreadMethods.java
public int getMinutesBetweenNowAndSnapshot(Snapshot snapshot) { DateTime now = new DateTime(); DateTime dt = new DateTime(snapshot.getStartTime()); return Minutes.minutesBetween(dt, now).getMinutes(); }
From source file:com.popdeem.sdk.uikit.utils.PDUIUtils.java
License:Open Source License
/** * Method to calculate the time until (Needs refactoring) * * @param expiryTimeInSeconds {@link Long} value for expiry time in seconds * @param nonClaimedReward {@link Boolean} * @param isSweepstakes {@link Boolean} * @return {@link String} value for time until *//*from w ww . ja v a 2 s . co m*/ public static String timeUntil(long expiryTimeInSeconds, boolean nonClaimedReward, boolean isSweepstakes) { final DateTime now = DateTime.now(); final DateTime expiry = new DateTime(expiryTimeInSeconds * 1000); // Check if reward has expired if (expiry.isBefore(now)) { return "Reward has expired"; } // Days int days = Days.daysBetween(now, expiry).getDays(); if (days == 1) { if (isSweepstakes) { return "1 day"; } else { return nonClaimedReward ? "1 day remaining" : "Expires in 1 day"; } } if (days > 1) { if (isSweepstakes) { return days + " days"; } else { return nonClaimedReward ? days + " days remaining" : "Expires in " + days + " days"; } } // Hours int hours = Hours.hoursBetween(now, expiry).getHours(); if (hours == 1) { if (isSweepstakes) { return "1 hour"; } else { return nonClaimedReward ? "1 hour remaining" : "Expires in 1 hour"; } } if (hours > 1) { if (isSweepstakes) { return hours + " hours"; } else { return nonClaimedReward ? hours + " hours remaining" : "Expires in " + hours + " hours"; } } // Minutes int minutes = Minutes.minutesBetween(now, expiry).getMinutes(); if (minutes == 1) { if (isSweepstakes) { return "1 minute"; } else { return nonClaimedReward ? "1 minute remaining" : "Expires in 1 minute"; } } if (isSweepstakes) { return minutes + " minutes"; } else return nonClaimedReward ? minutes + " minutes remaining" : "Expires in " + minutes + " minutes"; }
From source file:com.rapidminer.operator.GenerateDateSeries.java
License:Open Source License
private long calculateNumberOfExample(DateTime startTime, DateTime endTime) { // TODO Auto-generated method stub long valuetoReturn = 0; try {// w w w . j a v a 2s . c o m //getParameterAsString(key) switch (getParameterAsString(PARAMETER_INTERVALTYPE)) { case "YEAR": Years year = Years.yearsBetween(startTime, endTime); valuetoReturn = year.getYears() / getParameterAsInt(INTERVAL); break; case "MONTH": Months month = Months.monthsBetween(startTime, endTime); valuetoReturn = month.getMonths() / getParameterAsInt(INTERVAL); break; case "DAY": Days days = Days.daysBetween(startTime, endTime); valuetoReturn = days.getDays() / getParameterAsInt(INTERVAL); break; case "HOUR": Hours hours = Hours.hoursBetween(startTime, endTime); valuetoReturn = hours.getHours() / getParameterAsInt(INTERVAL); break; case "MINUTE": Minutes minute = Minutes.minutesBetween(startTime, endTime); valuetoReturn = minute.getMinutes() / getParameterAsInt(INTERVAL); break; case "SECOND": Seconds second = Seconds.secondsBetween(startTime, endTime); valuetoReturn = second.getSeconds() / getParameterAsInt(INTERVAL); break; case "MILLISECOND": // Milliseconds millisecond = milli long milli = endTime.getMillis() - startTime.getMillis(); valuetoReturn = milli / getParameterAsInt(INTERVAL); break; default: valuetoReturn = 0; } } catch (Exception e) { valuetoReturn = 0; } return valuetoReturn; }
From source file:com.smict.person.data.DoctorData.java
/** * Add doctor's workday depend on month pattern. * @author anubissmile//from w w w . j a v a 2 s. c o m * @param DoctorModel docModel * @param DoctTimeModel docTimeModel * @return int rec | Count of record that get affected. */ public int addDoctorWorkdayPattern(DoctorModel docModel, DoctTimeModel docTimeModel) { DateUtil dt = new DateUtil(); int key = 0; String[] workMonth; List<String> insertVal = new ArrayList<String>(); DateTime firstOfMonth, endOfMonth, nowDate; DateTimeFormatter dayName = DateTimeFormat.forPattern("E"); DateTimeFormatter fullDateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter fullDate = DateTimeFormat.forPattern("yyyy-MM-dd"); String day, fullDay; String startDateTime, endDateTime; int workMinutes; /** * Loop month. */ for (String month : docTimeModel.getWork_month()) { /** * Convert BE. to AD. */ workMonth = month.split("-"); workMonth[1] = String.valueOf(Integer.parseInt(workMonth[1]) - 543); /** * Make first date of month. */ nowDate = firstOfMonth = DateTime.parse(workMonth[1] + "-" + workMonth[0] + "-" + "01"); System.out.println(firstOfMonth); /** * Find Maximum date of month. */ endOfMonth = firstOfMonth.dayOfMonth().withMaximumValue(); System.out.println(endOfMonth); /** * Loop day */ while (Days.daysBetween(nowDate, endOfMonth).getDays() >= 0) { /** * Get day name. */ day = dayName.print(nowDate); fullDay = fullDate.print(nowDate); System.out.print(day.concat(" | ")); System.out.print(fullDay.concat(" | ")); System.out.println(nowDate); /** * Fetch time range by day */ //Mon // ('1', '2017-06-01 05:23:24', '2017-06-01 15:23:24', '25', '431', '0', '0000-00-00 00:00:01', '0000-00-00 00:00:01') if ((day.equals("Mon") || day.equals(".")) && (!docTimeModel.getTime_in_mon().get(key).equals("00:00") || !docTimeModel.getTime_out_mon().get(key).equals("00:00"))) { workMinutes = Minutes.minutesBetween(LocalTime.parse(docTimeModel.getTime_in_mon().get(key)), LocalTime.parse(docTimeModel.getTime_out_mon().get(key))).getMinutes(); startDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_in_mon().get(key)).concat(":00"); endDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_out_mon().get(key)).concat(":00"); insertVal.add(" ('" + docModel.getDoctorID() + "', '" + startDateTime + "', '" + endDateTime + "', '" + workMinutes + "', '" + docModel.getBranch_id() + "', '0', '1', '0000-00-00 00:00:01', '0000-00-00 00:00:01') "); nowDate = nowDate.plusDays(1); continue; } //Tue if ((day.equals("Tue") || day.equals(".")) && (!docTimeModel.getTime_in_tue().get(key).equals("00:00") || !docTimeModel.getTime_out_tue().get(key).equals("00:00"))) { workMinutes = Minutes.minutesBetween(LocalTime.parse(docTimeModel.getTime_in_tue().get(key)), LocalTime.parse(docTimeModel.getTime_out_tue().get(key))).getMinutes(); startDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_in_tue().get(key)).concat(":00"); endDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_out_tue().get(key)).concat(":00"); insertVal.add(" ('" + docModel.getDoctorID() + "', '" + startDateTime + "', '" + endDateTime + "', '" + workMinutes + "', '" + docModel.getBranch_id() + "', '0', '1', '0000-00-00 00:00:01', '0000-00-00 00:00:01') "); nowDate = nowDate.plusDays(1); continue; } //Wed if ((day.equals("Wed") || day.equals(".")) && (!docTimeModel.getTime_in_wed().get(key).equals("00:00") || !docTimeModel.getTime_out_wed().get(key).equals("00:00"))) { workMinutes = Minutes.minutesBetween(LocalTime.parse(docTimeModel.getTime_in_wed().get(key)), LocalTime.parse(docTimeModel.getTime_out_wed().get(key))).getMinutes(); startDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_in_wed().get(key)).concat(":00"); endDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_out_wed().get(key)).concat(":00"); insertVal.add(" ('" + docModel.getDoctorID() + "', '" + startDateTime + "', '" + endDateTime + "', '" + workMinutes + "', '" + docModel.getBranch_id() + "', '0', '1', '0000-00-00 00:00:01', '0000-00-00 00:00:01') "); nowDate = nowDate.plusDays(1); continue; } //Thu if ((day.equals("Thu") || day.equals(".")) && (!docTimeModel.getTime_in_thu().get(key).equals("00:00") || !docTimeModel.getTime_out_thu().get(key).equals("00:00"))) { workMinutes = Minutes.minutesBetween(LocalTime.parse(docTimeModel.getTime_in_thu().get(key)), LocalTime.parse(docTimeModel.getTime_out_thu().get(key))).getMinutes(); startDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_in_thu().get(key)).concat(":00"); endDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_out_thu().get(key)).concat(":00"); insertVal.add(" ('" + docModel.getDoctorID() + "', '" + startDateTime + "', '" + endDateTime + "', '" + workMinutes + "', '" + docModel.getBranch_id() + "', '0', '1', '0000-00-00 00:00:01', '0000-00-00 00:00:01') "); nowDate = nowDate.plusDays(1); continue; } //Fri if ((day.equals("Fri") || day.equals(".")) && (!docTimeModel.getTime_in_fri().get(key).equals("00:00") || !docTimeModel.getTime_out_fri().get(key).equals("00:00"))) { workMinutes = Minutes.minutesBetween(LocalTime.parse(docTimeModel.getTime_in_fri().get(key)), LocalTime.parse(docTimeModel.getTime_out_fri().get(key))).getMinutes(); startDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_in_fri().get(key)).concat(":00"); endDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_out_fri().get(key)).concat(":00"); insertVal.add(" ('" + docModel.getDoctorID() + "', '" + startDateTime + "', '" + endDateTime + "', '" + workMinutes + "', '" + docModel.getBranch_id() + "', '0', '1', '0000-00-00 00:00:01', '0000-00-00 00:00:01') "); nowDate = nowDate.plusDays(1); continue; } //Sat if ((day.equals("Sat") || day.equals(".")) && (!docTimeModel.getTime_in_sat().get(key).equals("00:00") || !docTimeModel.getTime_out_sat().get(key).equals("00:00"))) { workMinutes = Minutes.minutesBetween(LocalTime.parse(docTimeModel.getTime_in_sat().get(key)), LocalTime.parse(docTimeModel.getTime_out_sat().get(key))).getMinutes(); startDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_in_sat().get(key)).concat(":00"); endDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_out_sat().get(key)).concat(":00"); insertVal.add(" ('" + docModel.getDoctorID() + "', '" + startDateTime + "', '" + endDateTime + "', '" + workMinutes + "', '" + docModel.getBranch_id() + "', '0', '1', '0000-00-00 00:00:01', '0000-00-00 00:00:01') "); nowDate = nowDate.plusDays(1); continue; } //Sun if ((day.equals("Sun") || day.equals(".")) && (!docTimeModel.getTime_in_sun().get(key).equals("00:00") || !docTimeModel.getTime_out_sun().get(key).equals("00:00"))) { workMinutes = Minutes.minutesBetween(LocalTime.parse(docTimeModel.getTime_in_sun().get(key)), LocalTime.parse(docTimeModel.getTime_out_sun().get(key))).getMinutes(); startDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_in_sun().get(key)).concat(":00"); endDateTime = fullDate.print(nowDate).toString().concat(" ") .concat(docTimeModel.getTime_out_sun().get(key)).concat(":00"); insertVal.add(" ('" + docModel.getDoctorID() + "', '" + startDateTime + "', '" + endDateTime + "', '" + workMinutes + "', '" + docModel.getBranch_id() + "', '0', '1', '0000-00-00 00:00:01', '0000-00-00 00:00:01') "); nowDate = nowDate.plusDays(1); continue; } /** * Plus one day. */ nowDate = nowDate.plusDays(1); } ++key; } String SQL = StringUtils.join(insertVal, ", "); SQL = "INSERT INTO `doctor_workday` " + "(`doctor_id`, `start_datetime`, " + "`end_datetime`, `work_hour`, " + "`branch_id`, `branch_room_id`, " + "`checkin_status`, `checkin_datetime`, `checkout_datetime`) " + "VALUES ".concat(SQL); agent.connectMySQL(); agent.begin(); int rec = agent.exeUpdate(SQL); agent.commit(); agent.disconnectMySQL(); return rec; }
From source file:com.sonicle.webtop.calendar.CalendarManager.java
License:Open Source License
private void fillExportMapDates(HashMap<String, Object> map, DateTimeZone timezone, VVEventInstance sei) throws Exception { DateTime startDt = sei.getStartDate().withZone(timezone); map.put("startDate", startDt); map.put("startTime", startDt); DateTime endDt = sei.getEndDate().withZone(timezone); map.put("endDate", endDt); map.put("endTime", endDt); map.put("timezone", sei.getTimezone()); map.put("duration", Minutes.minutesBetween(sei.getEndDate(), sei.getStartDate()).size()); }
From source file:com.sonicle.webtop.calendar.job.RemoteCalendarSyncJob.java
License:Open Source License
private boolean isSyncNeeded(Calendar cal, DateTime now) { if (cal.getRemoteSyncTimestamp() == null) return true; return Minutes.minutesBetween(cal.getRemoteSyncTimestamp(), now).getMinutes() >= cal .getRemoteSyncFrequency();// w ww. j a v a 2 s . c om }
From source file:com.sonicle.webtop.contacts.job.RemoteCategorySyncJob.java
License:Open Source License
private boolean isSyncNeeded(Category cat, DateTime now) { if (cat.getRemoteSyncTimestamp() == null) return true; return Minutes.minutesBetween(cat.getRemoteSyncTimestamp(), now).getMinutes() >= cat .getRemoteSyncFrequency();/* w ww. j a v a 2s . c om*/ }
From source file:com.tripadvisor.seekbar.ClockView.java
License:Apache License
public void setNewCurrentTime(DateTime newCurrentTime) { if (mValidTimeInterval != null && newCurrentTime != null && mNewCurrentTime != null && mValidTimeInterval.contains(newCurrentTime)) { int diffInMinutes = Minutes.minutesBetween(mNewCurrentTime, newCurrentTime).getMinutes(); mCircularClockSeekBar.moveToDelta(mCurrentValidProgressDelta, diffInMinutes / 2); setClockText(mCurrentValidTime); }/* w w w. j av a 2 s.c om*/ }