List of usage examples for org.joda.time LocalTime getHourOfDay
public int getHourOfDay()
From source file:business.RegistroBO.java
public LocalTime getLateTimeByMonth(Date dt) { LocalTime result = new LocalTime(0, 0); try {//from w ww .jav a2 s . c o m List<Registro> list = registroDao.getListByMonth(dt); for (Registro reg : list) { LocalTime tmp = getLateTime(reg); if ((tmp.getHourOfDay() > 0) || (tmp.getMinuteOfHour() > 0)) { result = result.plusHours(tmp.getHourOfDay()); result = result.plusMinutes(tmp.getMinuteOfHour()); } } } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:business.RegistroBO.java
/** * * @param beginDate/* ww w .j av a 2s. c o m*/ * @param endDate * @return */ public LocalTime getOvertime(Date beginDate, Date endDate) { LocalTime result = new LocalTime(0, 0); try { List<Registro> list = registroDao.getListBetween(beginDate, endDate); for (Registro reg : list) { //zerando a data para comparar Calendar cal = Calendar.getInstance(); cal.setTime(reg.getDate()); Calendar dateCalendar = new GregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); if ((dateCalendar.getTime().compareTo(beginDate) >= 0) && (dateCalendar.getTime().compareTo(endDate) <= 0)) { LocalTime tmp = getLateLimitedTime(reg); // if ((tmp.getHourOfDay() > 0) || (tmp.getMinuteOfHour() > 0)) { // result = result.plusHours(tmp.getHourOfDay()); // result = result.plusMinutes(tmp.getMinuteOfHour()); // } if ((reg.getTotalHoras().getHourOfDay() >= Constants.TOTAL_LIMIT.getHourOfDay()) && (reg.getTotalHoras().getMinuteOfHour() >= Constants.TOTAL_LIMIT.getMinuteOfHour())) { int h = (reg.getTotalHoras().getHourOfDay() + tmp.getHourOfDay()) - (Constants.TOTAL_LIMIT.getHourOfDay()); int m = tmp.getMinuteOfHour() + reg.getTotalHoras().getMinuteOfHour(); result = result.plusHours(h); result = result.plusMinutes(m); } } } } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:business.RegistroBO.java
public LocalTime getLateTime(Registro reg) { LocalTime result = new LocalTime(0, 0); try {/*from w w w . j a va 2 s.co m*/ //calcula o tempo que infrigiu o horrio ncleo result = getLateLimitedTime(reg); //calcula o tempo que falta para a carga diria de trabalho if ((reg.getTotalHoras().getHourOfDay() < Constants.TOTAL_LIMIT.getHourOfDay()) && (reg.getTotalHoras().getMinuteOfHour() > Constants.TOTAL_LIMIT.getMinuteOfHour())) { int h = (Constants.TOTAL_LIMIT.getHourOfDay() - 1) - reg.getTotalHoras().getHourOfDay(); int m = 60 - reg.getTotalHoras().getMinuteOfHour(); result = result.plusHours(h - result.getHourOfDay()); result = result.plusMinutes(m - result.getMinuteOfHour()); } } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:ch.eitchnet.android.mabea.MabeaConnection.java
License:Open Source License
/** * @param stateChange// w ww . j ava 2 s.c o m * @param stateChange2 */ private void simulateAction(State previousState, State stateChange) { Logger.i(TAG, "simulateAction", "Simulating state change from " + previousState + " to " + stateChange); String name = "von Burg"; String balanceS = "-1:7 (Std:Min)"; String remainingVacationS = "21,5 Tage"; String stateS; LocalTime now = LocalTime.now(); String time = "(" + now.getHourOfDay() + ":" + now.getMinuteOfHour() + ")"; if (stateChange == State.LOGGED_IN) { stateS = "Anwesend " + time; } else stateS = "Abwesend " + time; try { Duration balance = MabeaParsing.parseBalance(balanceS); Duration remainingVacation = MabeaParsing.parseRemainingVacation(remainingVacationS); MabeaState.State state = MabeaParsing.parseState(stateS); LocalDateTime stateTime = MabeaParsing.parseStateTime(stateS); this.mabeaState = new MabeaState(name, balance, remainingVacation, stateTime, state); } catch (MabeaParsingException e) { this.connectionError = e; } }
From source file:ch.oakmountain.tpa.parser.TpaParser.java
License:Apache License
/** * Put the train path ids in the format <train_path_slot_id><hour_of_day_>-<three_digit_sequence_number_within_hour> * * @param wsName/*from www . j a va 2 s . c om*/ * @param rowsFrom * @param cols */ private void correctTrainPathIds(String wsName, int rowsFrom, Map<ColumnIdentifier, Integer> cols) { Sheet sheet = wb.getSheet(wsName); for (int i = rowsFrom; i <= sheet.getLastRowNum(); i++) { Row row = sheet.getRow(i); if (row == null) { continue; } Map<ColumnIdentifier, String> line = getWorksheetPointerStringMap(cols, row); String uncorrectedSlotName = line.get(trainPathLayout.ID); if (StringUtils.isBlank(uncorrectedSlotName)) { continue; } try { LocalTime startTime = LocalTime.parse(line.get(trainPathLayout.DEPTIME)); String correctedSlotName = getNextSlotId(wsName, startTime.getHourOfDay()); if (!correctedSlotName.equals(uncorrectedSlotName)) { LOGGER.warn("Correcting slot name " + uncorrectedSlotName + " => " + correctedSlotName); row.getCell(cols.get(trainPathLayout.ID)).setCellValue(correctedSlotName); } } catch (IllegalArgumentException e) { LOGGER.warn(corrupt_input, "Illegal start time \"" + line.get(trainPathLayout.DEPTIME) + "\" for slot " + uncorrectedSlotName + " in sheet " + wsName + " found; skipping this slot.", e); continue; } } }
From source file:ch.oakmountain.tpa.solver.PeriodicalTrainPathSlot.java
License:Apache License
public PeriodicalTrainPathSlot(String trainPathSectionName, String name, LocalTime startTime, LocalTime endTime, SystemNode from, SystemNode to, Periodicity periodicity) { this.trainPathSectionName = trainPathSectionName; this.periodicity = periodicity; this.name = name; this.startTime = startTime; this.endTime = endTime; this.from = from; this.to = to; for (Integer day : periodicity.getWeekDays()) { PeriodicalTimeFrame start = new PeriodicalTimeFrame(day, startTime.getHourOfDay(), startTime.getMinuteOfHour()); PeriodicalTimeFrame end = new PeriodicalTimeFrame(day, endTime.getHourOfDay(), endTime.getMinuteOfHour()); if (end.isBefore(start)) { end = end.plusHours(24);//from ww w . jav a 2 s . c om } if (!end.isWithinBounds(start, start.plusDays(1))) { throw new IllegalArgumentException("end " + end + " must be within 24h from " + start); } TrainPathSlot tp = new TrainPathSlot(name + "_" + day, start, end, from, to, this); slots[day] = tp; } }
From source file:ch.oakmountain.tpa.solver.TrainPathApplication.java
License:Apache License
public TrainPathApplication(String name, SystemNode from, SystemNode to, LocalTime startTime, LocalTime endTime, Periodicity periodicity, int hardMaximumEarlierDeparture, int hardMinimumDwellTime, int hardMaximumLaterArrival) { this.name = name; this.periodicity = periodicity; this.from = from; this.to = to; this.startTime = startTime; this.endTime = endTime; for (Integer day : periodicity.getWeekDays()) { PeriodicalTimeFrame start = new PeriodicalTimeFrame(day, startTime.getHourOfDay(), startTime.getMinuteOfHour()); PeriodicalTimeFrame end = new PeriodicalTimeFrame(day, endTime.getHourOfDay(), endTime.getMinuteOfHour()); if (end.isBefore(start)) { end = new PeriodicalTimeFrame(PeriodicalTimeFrame.nextDayOfWeek(day), endTime.getHourOfDay(), endTime.getMinuteOfHour()); }/*from ww w .j a va 2 s.c o m*/ SimpleTrainPathApplication r = new SimpleTrainPathApplication(name + "_" + day, from, to, start, end, this, hardMaximumEarlierDeparture, hardMinimumDwellTime, hardMaximumLaterArrival); simpleTrainPathApplications[day] = r; } }
From source file:cherry.goods.util.JodaTimeUtil.java
License:Apache License
/** * @param ltm ???{@link LocalTime}//from w w w .jav a 2 s . c om * @return ?????{@link Calendar}(?)????????(?1970-01-01) */ public static Calendar getCalendar(LocalTime ltm) { Calendar cal = Calendar.getInstance(); cal.set(1970, 0, 1, ltm.getHourOfDay(), ltm.getMinuteOfHour(), ltm.getSecondOfMinute()); cal.set(MILLISECOND, ltm.getMillisOfSecond()); return cal; }
From source file:com.alliander.osgp.domain.core.valueobjects.smartmetering.CosemTime.java
License:Open Source License
public CosemTime(final LocalTime time) { this(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond() / 10); }
From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemTimeDto.java
License:Open Source License
public CosemTimeDto(final LocalTime time) { this(time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), time.getMillisOfSecond() / 10); }