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:hydrometeo_analysis.TidesAndTimeManager.java
private static String createStringSQL_T(float HInterval, float i, LocalTime T) { //i = i - HInterval; int aux = (int) (60 * Math.abs(HInterval)); int aux2 = (aux / 2) - 1; if (HInterval == 0.25) aux2 = aux2 + 1;/*from w w w . j av a 2 s . com*/ aux2 += aux * i; LocalTime endT = T.plusMinutes(aux2); String h = Integer.toString(endT.getHourOfDay()); String m = Integer.toString(endT.getMinuteOfHour()); if (h.length() == 1) h = "0" + h; if (m.length() == 1) m = "0" + m; String endTime = "'" + h + ":" + m + ":00" + "'"; LocalTime startT = T.plusMinutes((aux2 + 1) - aux); h = Integer.toString(startT.getHourOfDay()); m = Integer.toString(startT.getMinuteOfHour()); if (h.length() == 1) h = "0" + h; if (m.length() == 1) m = "0" + m; String startTime = "'" + h + ":" + m + ":00" + "'"; if (i >= 0 && !T.isBefore(endT)) { endTime = "'23:59:59'"; int minutes = Minutes.minutesBetween(startT, createLocalTime("23:59:59")).getMinutes(); if (minutes > 60 * Math.abs(HInterval)) startTime = "'23:59:59'"; } else if (i <= 0 && T.isBefore(startT)) { startTime = "'00:00:00'"; int minutes = Minutes.minutesBetween(createLocalTime("00:00:00"), endT).getMinutes(); if (minutes > 60 * Math.abs(HInterval)) endTime = "'00:00:00'"; } return "`time` BETWEEN " + "time(" + startTime + ")" + " AND " + "time(" + endTime + ")"; }
From source file:hydrometeo_analysis.TidesAndTimeManager.java
private String[] getDHandDT(String[] row, LocalTime H_High, int minutes, int index) { if (minutes >= 0) {//after high if (index >= 7 || row[index + 2] == null) return new String[] { "NULL", "NULL" }; String DT = "NULL", DH = "NULL"; if (index + 1 < row.length || index + 3 < row.length) DT = "'" + Float.toString(Float.parseFloat(row[index + 1]) - Float.parseFloat(row[index + 3])) + "'"; //HIGH - LOW if (index + 2 < row.length) DH = "'" + Integer.toString( Minutes.minutesBetween(H_High, createLocalTime(row[index + 2])).getMinutes()) + "'"; return new String[] { DT, DH }; } else {//before high if (row[index - 2] == null) return new String[] { "NULL", "NULL" }; String DT = "NULL"; if (index + 1 < row.length) DT = "'" + Float.toString(Float.parseFloat(row[index + 1]) - Float.parseFloat(row[index - 1])) + "'"; //HIGH - LOW String DH = "'" + Integer.toString(Minutes.minutesBetween(createLocalTime(row[index - 2]), H_High).getMinutes()) + "'"; return new String[] { DT, DH }; }/*from w w w. j ava 2s. c o m*/ }
From source file:hydrometeo_analysis.TidesAndTimeManager.java
private Object[] getDistH(LocalTime time, LocalTime H_First_High, LocalTime H_Second_High) { if (H_First_High != null && H_Second_High == null) { int minutes = (-1) * Minutes.minutesBetween(time, H_First_High).getMinutes(); //(+ o -) return new Object[] { true, Integer.toString(minutes) };//true = first High, false = Second High //System.out.println("Start: " + time.toString() + " End: " + H_First_High.toString() + " " + minutes ); } else if (H_First_High == null && H_Second_High != null) { int minutes = (-1) * Minutes.minutesBetween(time, H_Second_High).getMinutes(); //(+ o -) return new Object[] { false, Integer.toString(minutes) }; } else if (H_First_High != null && H_Second_High != null) { int minutesFirst = (-1) * Minutes.minutesBetween(time, H_First_High).getMinutes(); //(+ o -) int minutesSecond = (-1) * Minutes.minutesBetween(time, H_Second_High).getMinutes(); if (Math.abs(minutesFirst) < Math.abs(minutesSecond)) { return new Object[] { true, Integer.toString(minutesFirst) }; } else {// w w w. ja v a 2 s .c o m return new Object[] { false, Integer.toString(minutesSecond) }; } } else {//BOTH null return null; } }
From source file:ManageBean.PostController.java
public void CaculateTime() { obj2 = new ArrayList<>(); DateTime datenow = new DateTime(); for (int i = 0; i < list.size(); i++) { DateTime datepost = new DateTime(list.get(i).getPostDate()); Dates Date = new Dates(); //Date.setDate(Days.daysBetween(datepost, datenow).getDays()); if (Days.daysBetween(datepost, datenow).getDays() > 0) { Date.setTime("cch y " + Days.daysBetween(datepost, datenow).getDays() + " ngy"); } else if ((Hours.hoursBetween(datepost, datenow).getHours() % 24) > 0) { Date.setTime("cch y " + Hours.hoursBetween(datepost, datenow).getHours() % 24 + "gi?"); } else if ((Minutes.minutesBetween(datepost, datenow).getMinutes() % 60) > 0) { Date.setTime(/*from ww w . j a v a2 s. c o m*/ "cch y " + Minutes.minutesBetween(datepost, datenow).getMinutes() % 60 + " pht"); } else { Date.setTime( "cch y " + Seconds.secondsBetween(datepost, datenow).getSeconds() % 60 + " giy"); } obj2.add(Date); } }
From source file:net.naonedbus.card.impl.HoraireCard.java
License:Open Source License
@Override public void onLoadFinished(final Loader<List<Horaire>> loader, final List<Horaire> horaires) { if (horaires != null && !horaires.isEmpty()) { final DateTime now = new DateTime().withSecondOfMinute(0).withMillisOfSecond(0); int minutes; int indexView = 0; int indexHoraire = -1; int firstNextHoraireIndex = -1; // Grer le prcdent passage si prsent DateTime date = new DateTime(); for (int i = 0; i < horaires.size(); i++) { date = horaires.get(i).getHoraire(); if (date.isBefore(now)) { indexHoraire = i;/*from w ww. j a v a 2s. c o m*/ } else { break; } } if (indexHoraire == -1) { // Pas de prcdent indexView = 1; indexHoraire = 0; firstNextHoraireIndex = 0; mHoraireViews.get(0).setVisibility(View.GONE); mDelaiViews.get(0).setVisibility(View.GONE); } else { // Afficher le prcdent firstNextHoraireIndex = 1; mHoraireViews.get(0).setVisibility(View.VISIBLE); mDelaiViews.get(0).setVisibility(View.VISIBLE); } while (indexHoraire < horaires.size() && indexView < mHoraireViews.size()) { String delai = ""; final Horaire horaire = horaires.get(indexHoraire); final TextView horaireView = mHoraireViews.get(indexView); CharSequence formattedTime = FormatUtils.formatTimeAmPm(getContext(), mTimeFormat.format(horaire.getHoraire().toDate())); if (horaire.getTerminus() != null) { CharSequence terminusLetter = mTerminusManager.getTerminusLetter(horaire.getTerminus()); terminusLetter = FormatUtils.formatTerminusLetter(getContext(), terminusLetter); if (indexHoraire > firstNextHoraireIndex) { formattedTime = TextUtils.concat(formattedTime, "\n", terminusLetter); } else { formattedTime = TextUtils.concat(formattedTime, terminusLetter); } } horaireView.setText(formattedTime); if (indexView > 0) { minutes = Minutes .minutesBetween(now, new DateTime(horaire.getHoraire()).withSecondOfMinute(0).withMillisOfSecond(0)) .getMinutes(); if (minutes > 60) { delai = getString(R.string.msg_depart_heure_short, minutes / 60); } else if (minutes > 0) { delai = getString(R.string.msg_depart_min_short, minutes); } else if (minutes == 0) { delai = getString(R.string.msg_depart_proche); } mDelaiViews.get(indexView).setText(delai); } indexHoraire++; indexView++; } // Add terminus information mTerminusView.removeAllViews(); final Map<String, String> terminus = mTerminusManager.getTerminus(); for (final Entry<String, String> item : terminus.entrySet()) { final TextView textView = (TextView) mLayoutInflater.inflate(R.layout.card_horaire_terminus, mTerminusView, false); textView.setText(item.getValue() + " " + item.getKey()); mTerminusView.addView(textView); } showContent(); } else { showMessage(R.string.msg_nothing_horaires); } }
From source file:net.naonedbus.fragment.impl.HorairesFragment.java
License:Open Source License
/** * Mettre jour les informations de dlais */// www. j av a 2 s . co m private void updateItemsTime() { final Long currentTime = new DateTime().minusMinutes(5).withSecondOfMinute(0).withMillisOfSecond(0) .getMillis(); final DateTime now = new DateTime().withSecondOfMinute(0).withMillisOfSecond(0); int nextHorairePosition = -1; int delay; DateTime itemDateTime; Horaire horaire; for (int i = 0; i < mAdapter.getCount(); i++) { horaire = mAdapter.getItem(i); if (horaire instanceof EmptyHoraire) { continue; } itemDateTime = new DateTime(horaire.getHoraire()).withSecondOfMinute(0).withMillisOfSecond(0); delay = Minutes.minutesBetween(now, itemDateTime).getMinutes(); if (delay > 0 && delay < 60) { horaire.setDelai(getString(R.string.msg_depart_min, delay)); } else if (delay == 0) { horaire.setDelai(getString(R.string.msg_depart_proche)); } else { horaire.setDelai(null); } horaire.setBeforeNow(itemDateTime.isBefore(now)); // Recherche le prochain horaire if (nextHorairePosition == -1 && (horaire.getHoraire().isAfterNow() || horaire.getHoraire().isEqualNow())) { nextHorairePosition = mAdapter.getPosition(horaire); } } // Si aucun prochain horaire n'est trouv, slectionner le dernier if (nextHorairePosition == -1) { nextHorairePosition = mAdapter.getCount() - 1; } mAdapter.notifyDataSetChanged(); if (nextHorairePosition != -1 && mIsFirstLoad) { getListView().setSelection(nextHorairePosition); mIsFirstLoad = false; } }
From source file:net.naonedbus.manager.impl.HoraireManager.java
License:Open Source License
/** * Rcuprer le nombre de minutes jusqu'au prochain horaire. * /*from w w w . j a va 2s . c om*/ * @throws IOException */ public Integer getMinutesToNextSchedule(final ContentResolver contentResolver, final Arret arret) throws IOException { final List<Horaire> nextSchedules = getNextSchedules(contentResolver, arret, new DateMidnight(), 1); Integer result = null; if (nextSchedules.size() > 0) { final Horaire next = nextSchedules.get(0); final DateTime itemDateTime = new DateTime(next.getHoraire()).withSecondOfMinute(0) .withMillisOfSecond(0); final DateTime now = new DateTime().withSecondOfMinute(0).withMillisOfSecond(0); result = Minutes.minutesBetween(now, itemDateTime).getMinutes(); } return result; }
From source file:net.sourceforge.fenixedu.domain.Lesson.java
License:Open Source License
private int getUnitMinutes() { return Minutes.minutesBetween(getBeginHourMinuteSecond(), getEndHourMinuteSecond()).getMinutes(); }
From source file:net.sourceforge.fenixedu.domain.Lesson.java
License:Open Source License
public Duration getTotalDuration() { return Minutes.minutesBetween(getBeginHourMinuteSecond(), getEndHourMinuteSecond()).toStandardDuration(); }
From source file:net.sourceforge.fenixedu.domain.Lesson.java
License:Open Source License
public double hoursAfter(int hour) { HourMinuteSecond afterHour = new HourMinuteSecond(hour, 0, 0); if (!getBeginHourMinuteSecond().isBefore(afterHour)) { return getUnitHours().doubleValue(); } else if (getEndHourMinuteSecond().isAfter(afterHour)) { return BigDecimal.valueOf(Minutes.minutesBetween(afterHour, getEndHourMinuteSecond()).getMinutes()) .divide(BigDecimal.valueOf(NUMBER_OF_MINUTES_IN_HOUR), 2, RoundingMode.HALF_UP).doubleValue(); }/*w ww. j a v a 2s.c o m*/ return 0.0; }