List of usage examples for org.joda.time Period toStandardMinutes
public Minutes toStandardMinutes()
From source file:au.com.scds.chats.dom.attendance.Attend.java
License:Apache License
@Action() public Attend updateDatesAndTimes(@ParameterLayout(named = "Start Date Time") DateTime start, @ParameterLayout(named = "End Date Time") DateTime end) { if (start != null && end != null) { if (end.isBefore(start)) { container.warnUser("end date & time is earlier than start date & time"); return this; }/*from w ww. ja va 2s .co m*/ if (end.getDayOfWeek() != start.getDayOfWeek()) { container.warnUser("end date and start date are different days of the week"); return this; } Period period = new Period(start.toLocalDateTime(), end.toLocalDateTime()); Float hours = ((float) period.toStandardMinutes().getMinutes()) / 60; if (hours > 12.0) { container.warnUser("end date & time and start date & time are not in the same 12 hour period"); return this; } setStartDateTime(start); setEndDateTime(end); setAttended(true); } return this; }
From source file:au.com.scds.chats.dom.call.ScheduledCall.java
License:Apache License
@Property(editing = Editing.DISABLED, notPersisted = true) @PropertyLayout(named = "Call Length in Hours", describedAs = "The interval that the participant attended the activity in hours") @MemberOrder(sequence = "6") @NotPersistent/* w ww. j a va 2s. c o m*/ public String getCallLength() { if (getStartDateTime() != null && getEndDateTime() != null) { Period per = new Period(getStartDateTime().toLocalDateTime(), getEndDateTime().toLocalDateTime()); Float hours = ((float) per.toStandardMinutes().getMinutes()) / 60; return hoursFormat.format(hours); } else return null; }
From source file:au.com.scds.chats.dom.volunteer.VolunteeredTime.java
License:Apache License
@Action() @MemberOrder(name = "enddatetime", sequence = "1") public VolunteeredTime updateDatesAndTimes(@ParameterLayout(named = "Start Date Time") DateTime start, @ParameterLayout(named = "End Date Time") DateTime end) { if (start != null && end != null) { if (end.isBefore(start)) { container.warnUser("end date & time is earlier than start date & time"); return this; }/*from w w w. jav a2s . c o m*/ if (end.getDayOfWeek() != start.getDayOfWeek()) { container.warnUser("end date and start date are different days of the week"); return this; } Period period = new Period(start.toLocalDateTime(), end.toLocalDateTime()); Float hours = ((float) period.toStandardMinutes().getMinutes()) / 60; if (hours > 12.0) { container.warnUser("end date & time and start date & time are not in the same 12 hour period"); return this; } setStartDateTime(start); setEndDateTime(end); } return this; }
From source file:au.com.scds.chats.dom.volunteer.VolunteeredTime.java
License:Apache License
@Property(editing = Editing.DISABLED, notPersisted = true) @PropertyLayout(named = "Effort in Hours", describedAs = "The interval of volunteer effort provided in hours") @MemberOrder(sequence = "13") @NotPersistent//from w w w . ja va 2s . com public String getEffortLength() { if (getStartDateTime() != null && getEndDateTime() != null) { Period per = new Period(getStartDateTime().toLocalDateTime(), getEndDateTime().toLocalDateTime()); Float hours = ((float) per.toStandardMinutes().getMinutes()) / 60; return hoursFormat.format(hours); } else return null; }
From source file:com.gmt2001.YouTubeAPIv3.java
License:Open Source License
public int[] GetVideoLength(String id) { com.gmt2001.Console.debug.println("YouTubeAPIv3.GetVideoLength Start id=" + id); JSONObject j = GetData(request_type.GET, "https://www.googleapis.com/youtube/v3/videos?id=" + id + "&key=" + apikey + "&part=contentDetails"); if (j.getBoolean("_success")) { if (j.getInt("_http") == 200) { JSONArray a = j.getJSONArray("items"); if (a.length() > 0) { JSONObject i = a.getJSONObject(0); JSONObject cd = i.getJSONObject("contentDetails"); PeriodFormatter formatter = ISOPeriodFormat.standard(); Period d = formatter.parsePeriod(cd.getString("duration")); if (cd.getString("duration").equalsIgnoreCase("PT0S")) { com.gmt2001.Console.debug.println("YouTubeAPIv3.GetVideoLength Fail (Live Stream)"); return new int[] { 123, 456, 7899 }; }//from ww w . j a va2 s. c o m //String d = cd.getString("duration").substring(2); int h, m, s; String hours = d.toStandardHours().toString().substring(2); h = Integer.parseInt(hours.substring(0, hours.indexOf("H"))); String minutes = d.toStandardMinutes().toString().substring(2); m = Integer.parseInt(minutes.substring(0, minutes.indexOf("M"))); String seconds = d.toStandardSeconds().toString().substring(2); s = Integer.parseInt(seconds.substring(0, seconds.indexOf("S"))); /* * if (d.contains("H")) { h = * Integer.parseInt(d.substring(0, d.indexOf("H"))); * * d = d.substring(0, d.indexOf("H")); } * * if (d.contains("M")) { m = * Integer.parseInt(d.substring(0, d.indexOf("M"))); * * d = d.substring(0, d.indexOf("M")); } * * s = Integer.parseInt(d.substring(0, d.indexOf("S"))); */ com.gmt2001.Console.debug.println("YouTubeAPIv3.GetVideoLength Success"); return new int[] { h, m, s }; } else { com.gmt2001.Console.debug.println("YouTubeAPIv3.GetVideoLength Fail"); return new int[] { 0, 0, 0 }; } } else { com.gmt2001.Console.debug.println("YouTubeAPIv3.GetVideoLength Fail2"); return new int[] { 0, 0, 0 }; } } com.gmt2001.Console.debug.println("YouTubeAPIv3.GetVideoLength Fail3"); return new int[] { 0, 0, 0 }; }
From source file:com.marand.thinkmed.medications.converter.ComplexMedicationFromEhrConverter.java
License:Open Source License
protected final void fillDoseElementFromOrderActivity(final ComplexDoseElementDto doseElement, final OrderActivity orderActivity, final boolean specificsPrefilled) { if (!specificsPrefilled) { final AdministrationDetailsCluster administration = orderActivity.getAdministrationDetails(); final Period duration = DvUtils.getDuration(administration.getDoseDuration()); if (duration != null) { doseElement.setDuration(duration.toStandardMinutes().getMinutes()); }/*from w w w.jav a 2 s. c o m*/ if (!administration.getInfusionAdministrationDetails().isEmpty()) { final InfusionAdministrationDetailsCluster infusionDetails = administration .getInfusionAdministrationDetails().get(0); if (infusionDetails.getDoseAdministrationRate() instanceof DvQuantity) { final DvQuantity administrationRateQuantity = (DvQuantity) infusionDetails .getDoseAdministrationRate(); doseElement.setRate(administrationRateQuantity.getMagnitude()); doseElement.setRateUnit(administrationRateQuantity.getUnits()); } if (infusionDetails.getDoseAdministrationFormula() instanceof DvQuantity) { final DvQuantity administrationRateFormula = (DvQuantity) infusionDetails .getDoseAdministrationFormula(); doseElement.setRateFormula(administrationRateFormula.getMagnitude()); doseElement.setRateFormulaUnit(administrationRateFormula.getUnits()); } } } }
From source file:com.mirth.connect.server.util.LoginRequirementsChecker.java
License:Open Source License
public String getPrintableStrikeTimeRemaining() { Period period; synchronized (userLoginStrikes) { period = new Period(getStrikeTimeRemaining()); }/*ww w. java 2s.c o m*/ PeriodFormatter periodFormatter; if (period.toStandardMinutes().getMinutes() > 0) { periodFormatter = new PeriodFormatterBuilder().printZeroNever().appendHours() .appendSuffix(" hour", " hours").appendSeparator(" and ").printZeroAlways().appendMinutes() .appendSuffix(" minute", " minutes").toFormatter(); } else { periodFormatter = new PeriodFormatterBuilder().printZeroAlways().appendSeconds() .appendSuffix(" second", " seconds").toFormatter(); } return periodFormatter.print(period); }
From source file:com.thinkbiganalytics.scheduler.util.TimerToCronExpression.java
License:Apache License
private static String getMinutesCron(Period p) { Integer min = p.getMinutes(); Minutes m = p.toStandardMinutes(); Integer minutes = m.getMinutes(); String str = "0" + (min > 0 ? "/" + min : ""); if (minutes > 60) { str = min + ""; }//from w w w . ja v a 2 s . c om return str; }
From source file:de.azapps.mirakel.sync.taskwarrior.model.TaskWarriorTaskSerializer.java
License:Open Source License
public static void handleRecurrence(final JsonObject json, final Recurring r) { if (r == null) { Log.wtf(TAG, "recurring is null"); return;/* w w w . j a v a2 s .c o m*/ } if (!r.getWeekdays().isEmpty()) { switch (r.getWeekdays().size()) { case 1: json.addProperty("recur", "weekly"); return; case 7: json.addProperty("recur", "daily"); return; case 5: final List<Integer> weekdays = r.getWeekdays(); for (Integer i = DateTimeConstants.MONDAY; i <= DateTimeConstants.FRIDAY; i++) { if (!weekdays.contains(i)) { Log.w(TAG, "unsupported recurrence"); return; } } json.addProperty("recur", "weekdays"); return; default: Log.w(TAG, "unsupported recurrence"); return; } } final long interval = r.getIntervalMs() / (1000L * 60L); if (interval > 0L) { Period p = r.getInterval(); if (r.getInterval().getMinutes() > 0) { json.addProperty("recur", p.toStandardMinutes().getMinutes() + "mins"); } else if (r.getInterval().getHours() > 0) { json.addProperty("recur", p.toStandardHours().getHours() + "hours"); } else if (r.getInterval().getDays() > 0) { json.addProperty("recur", p.toStandardDays().getDays() + "days"); } else if (r.getInterval().getWeeks() > 0) { json.addProperty("recur", p.toStandardWeeks().getWeeks() + "weeks"); } else if (r.getInterval().getMonths() > 0) { json.addProperty("recur", p.getMonths() + (12 * p.getYears()) + "months"); } else { json.addProperty("recur", p.getYears() + "years"); } } }
From source file:org.kalypso.ogc.sensor.timeseries.TimeseriesUtils.java
License:Open Source License
/** * This function guesses the timestamp of a given timeseries from several timsteps. Only timeseries with a timestep of * 1 day do have a timestamp.// w w w . ja va 2 s.c om * * @param timeseries * The tuple model of a timeseries. * @param timestep * The timestep of the timeseries. * @return The timestamp in UTC or null. */ public static LocalTime guessTimestamp(final ITupleModel timeseries, final Period timestep) throws SensorException { /* The timestamp is only relevant for day values. */ if (timestep != null && timestep.toStandardMinutes().getMinutes() == 1440) { /* Guess the timestamp of the timeseries. */ final TimestampGuesser guesser = new TimestampGuesser(timeseries, -1); return guesser.execute(); } return null; }