List of usage examples for org.joda.time LocalTime plusHours
public LocalTime plusHours(int hours)
From source file:business.RegistroBO.java
public LocalTime getLateTimeByMonth(Date dt) { LocalTime result = new LocalTime(0, 0); try {/* w ww . j a va2s . 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 a va 2 s . 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 ww .jav a 2s . c o 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:business.RegistroBO.java
private LocalTime getLateLimitedTime(Registro reg) { LocalTime result = new LocalTime(0, 0); try {//from w ww.ja v a 2 s .com if ((reg.getManha().getHourOfDay() >= Constants.MANHA_LIMIT.getHourOfDay()) && (reg.getManha().getMinuteOfHour() > Constants.MANHA_LIMIT.getMinuteOfHour())) { int h = reg.getManha().getHourOfDay() - Constants.MANHA_LIMIT.getHourOfDay(); int m = reg.getManha().getMinuteOfHour(); result = result.plusHours(h); result = result.plusMinutes(m); } if ((reg.getAlmoco().getHourOfDay() < Constants.ALMOCO_LIMIT.getHourOfDay()) && (reg.getAlmoco().getMinuteOfHour() >= Constants.ALMOCO_LIMIT.getMinuteOfHour())) { int h = (Constants.ALMOCO_LIMIT.getHourOfDay() - 1) - reg.getAlmoco().getHourOfDay(); int m = 60 - reg.getAlmoco().getMinuteOfHour(); result = result.plusHours(h); result = result.plusMinutes(m); } if ((reg.getAlmoco2().getHourOfDay() >= Constants.ALMOCO2_LIMIT.getHourOfDay()) && (reg.getAlmoco2().getMinuteOfHour() > Constants.ALMOCO2_LIMIT.getMinuteOfHour())) { int h = reg.getAlmoco2().getHourOfDay() - Constants.ALMOCO2_LIMIT.getHourOfDay(); int m = reg.getAlmoco2().getMinuteOfHour(); result = result.plusHours(h); result = result.plusMinutes(m); } if ((reg.getTarde().getHourOfDay() < Constants.TARDE_LIMIT.getHourOfDay()) && (reg.getTarde().getMinuteOfHour() >= Constants.TARDE_LIMIT.getMinuteOfHour())) { int h = (Constants.TARDE_LIMIT.getHourOfDay() - 1) - reg.getTarde().getHourOfDay(); int m = 60 - reg.getTarde().getMinuteOfHour(); result = result.plusHours(h); result = result.plusMinutes(m); } } catch (Exception e) { e.printStackTrace(); } return result; }
From source file:com.karthikb351.vitinfo2.fragment.schedule.ScheduleListAdapter.java
License:Open Source License
private void compareTimeAndUpdate(ScheduleView scheduleView, String startTime, String endTime) { // Formatting strings to get the nearest hours startTime = formatTime(startTime);//from w ww. j a v a2s . com endTime = formatTime(endTime); // Comparing time LocalTime nowTime = LocalTime.now(DateTimeZone.UTC); LocalTime floorTime = new LocalTime(startTime); LocalTime ceilTime = new LocalTime(endTime); // To correct the timezone difference nowTime = nowTime.plusHours(5); nowTime = nowTime.plusMinutes(30); boolean lowerCheck = nowTime.isAfter(floorTime) || nowTime.isEqual(floorTime); boolean upperCheck = nowTime.isBefore(ceilTime); boolean upperOverCheck = nowTime.isAfter(ceilTime) || nowTime.isEqual(ceilTime); if (lowerCheck && upperCheck) { scheduleView.setState(TimeLineView.STATE_CURRENT); } else if (lowerCheck && upperOverCheck) { scheduleView.setState(TimeLineView.STATE_FINISHED); } else { scheduleView.setState(TimeLineView.STATE_SCHEDULED); } }
From source file:com.metinkale.prayerapp.vakit.times.Times.java
License:Apache License
@NonNull private String adj(@NonNull String time, int t) { try {//from w w w. java 2s . c om double drift = getTZFix(); int[] adj = getMinuteAdj(); if ((drift == 0) && (adj[t] == 0)) { return time; } int h = (int) Math.round(drift - 0.5); int m = (int) ((drift - h) * 60); String[] s = time.split(":"); LocalTime lt = new LocalTime(Integer.parseInt(s[0]), Integer.parseInt(s[1]), 0); lt = lt.plusHours(h).plusMinutes(m).plusMinutes(adj[t]); time = lt.toString("HH:mm"); return time; } catch (Exception e) { Crashlytics.logException(e); return "00:00"; } }
From source file:com.prayer.vakit.times.Times.java
License:Apache License
private String adj(String time, int t) { try {//from w w w . ja va2s.c o m double drift = getTZFix(); int[] adj = getMinuteAdj(); if ((drift == 0) && (adj[t] == 0)) { return time; } int h = (int) Math.round(drift - 0.5); int m = (int) ((drift - h) * 60); String[] s = time.split(":"); LocalTime lt = new LocalTime(Integer.parseInt(s[0]), Integer.parseInt(s[1]), 0); lt = lt.plusHours(h).plusMinutes(m).plusMinutes(adj[t]); time = lt.toString("HH:mm"); return time; } catch (Exception e) { return "00:00"; } }
From source file:config.TimeManipulation.java
License:Open Source License
public String getServerTime(int Offset) { LocalTime Time = new LocalTime(); Time = Time.plusHours(Offset); DateTimeFormatter outputFormat = new DateTimeFormatterBuilder().appendPattern("HH:mm").toFormatter(); return Time.toString(outputFormat); }
From source file:javaapplication5.NewJFrame.java
public static LocalTime increaseTime(LocalTime time, int h, int m) { time = time.plusHours(h); time = time.plusMinutes(m);// w ww . j a va 2 s . c o m return time; }