Example #1
0
 public LocalDateTime getLocalDateTime(LocalDate selectedDate, LocalTime startTime) {
   return new LocalDateTime(
       selectedDate.getYear(),
       selectedDate.getMonthOfYear(),
       selectedDate.getDayOfMonth(),
       startTime.getHourOfDay(),
       startTime.getMinuteOfHour());
 }
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   Log.i(TAG, "On create view...");
   // Inflate the layout for this fragment
   LocalTime time = LocalTime.now();
   if (getArguments() != null) {
     time = new DateTime(getArguments().getLong(ARG_TIME)).toLocalTime();
   }
   View view = inflater.inflate(R.layout.fragment_time_picker, container, false);
   mTimePicker = (TimePicker) view.findViewById(R.id.time_picker);
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
     mTimePicker.setHour(time.getHourOfDay());
     mTimePicker.setMinute(time.getMinuteOfHour());
   } else {
     mTimePicker.setCurrentHour(time.getHourOfDay());
     mTimePicker.setCurrentMinute(time.getMinuteOfHour());
   }
   return view;
 }
Example #3
0
  public static String doTheActualFun() {
    int minutesLeft = 0;
    final LocalTime now = new LocalTime();

    if (hardcodedTimes[hardcodedTimes.length - 1].compareTo(now) <= 0) {
      return makeItNicer(-1);
    }

    LocalTime tmpLocalTimeCalculated;

    for (final LocalTime hardcodedTime : hardcodedTimes) {
      if (hardcodedTime.compareTo(now) >= 0) {
        tmpLocalTimeCalculated =
            hardcodedTime.minusHours(now.getHourOfDay()).minusMinutes(now.getMinuteOfHour());
        minutesLeft =
            tmpLocalTimeCalculated.getHourOfDay() * 60 + tmpLocalTimeCalculated.getMinuteOfHour();
        break;
      }
    }

    return makeItNicer(minutesLeft);
  }
Example #4
0
 @JsonIgnore
 public boolean isTodaysDosageResponseCaptured() {
   LocalDate today = DateUtil.today();
   LocalDate yesterday = today.minusDays(1);
   LocalTime localNow = DateUtil.now().toLocalTime();
   if (responseLastCapturedDate == null) {
     return false;
   }
   if (responseLastCapturedDate.equals(today)) {
     return true;
   }
   return responseLastCapturedDate.equals(yesterday)
       && new Time(localNow.getHourOfDay(), localNow.getMinuteOfHour()).isBefore(dosageTime);
 }
  @Override
  public List<UnidadeIndiceOEE> gerarUnidadesIndiceOEE(
      IndiceOEEPorHoraFilter filter, LocalDateTime dtHrInicio, LocalDateTime dtHrFim) {
    if (dtHrFim == null) {
      LocalTime horaAtual = new LocalTime();
      dtHrFim =
          new LocalDate()
              .toLocalDateTime(
                  new LocalTime(horaAtual.getHourOfDay(), horaAtual.getMinuteOfHour(), 0, 0));
    }
    List<UnidadeIndiceOEE> result = new ArrayList<UnidadeIndiceOEE>();

    int year = dtHrInicio.getYear();
    int month = dtHrInicio.getMonthOfYear();
    int day = dtHrInicio.getDayOfMonth();
    int hour = dtHrInicio.getHourOfDay();

    LocalDateTime dtHr = new LocalDateTime(year, month, day, hour, 0, 0, 0);

    while (dtHr.isBefore(dtHrFim)) {
      if (dtHr.toLocalDate().equals(filter.getDt())) {

        UnidadeIndiceOEE unidade = new UnidadeIndiceOEE();
        unidade.setInicio(dtHr);
        unidade.setFim(dtHr.plusMinutes(59));
        updateId(unidade);

        LocalDateTime inicio = dtHrInicio.isAfter(dtHr) ? dtHrInicio : unidade.getInicio();
        LocalDateTime fim = dtHr.plusHours(1);
        fim = dtHrFim.isAfter(fim) ? fim : dtHrFim;
        Integer tempoUtilMinutos = DateUtils.getDiferencaEmMinutos(inicio, fim);
        unidade.setTempoUtilMinutos(tempoUtilMinutos);

        result.add(unidade);
      }
      dtHr = dtHr.plusHours(1);
    }

    return result;
  }
Example #6
0
 /**
  * Constructor.
  *
  * @param localTime the time to be stored, not null
  */
 public Time(LocalTime localTime) {
   this(localTime.getHourOfDay(), localTime.getMinuteOfHour());
 }
Example #7
0
 private void timeCalculate() {
   LocalTime localTime = LocalTime.now();
   this.dayMinute = localTime.getHourOfDay() * 60 + localTime.getMinuteOfHour();
 }