List of usage examples for org.joda.time LocalDateTime now
public static LocalDateTime now()
ISOChronology
in the default time zone. From source file:curiosamente.com.app.activities.main.MainActivity.java
License:Apache License
public void startActivity() { // Set initial Fragment WaitingFragment waitingFragment = new WaitingFragment(); waitingFragment.setFragmentMessage(//from w ww. j av a2s . c om getBaseContext().getResources().getString(R.string.waiting_fragment_connecting_server)); FragmentManager fm = getFragmentManager(); FragmentTransaction fragmentTransaction = fm.beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.slide_in_right, 0); fragmentTransaction.replace(R.id.main_layout, waitingFragment, FRAGMENT_TAG); fragmentReplacementTimeStamp = LocalDateTime.now(); fragmentTransaction.commit(); fm.popBackStack(); if (BarManager.isABarSelectedAndValid(this)) { BarManager.updateSelectedBarTimeStamp(this); StatusManager.clearStatus(this); ThreadManager.callCheckStatus(this); } else { BarManager.getBars(this); } initDrawer(); }
From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.excelimport.ImportProcessRegistryCleanupTimer.java
License:Open Source License
@SuppressWarnings("boxing") private void createTimer() { if (LOGGER.isInfoEnabled()) { LOGGER.info(/*ww w . j a v a2 s. co m*/ "Starting the timer for the cleanup of the import queue. First run is scheduled at: {0} ({1} ms from now). Period is: {2} ms.", LocalDateTime.now().plusMillis(startupOffset).toString(), startupOffset, period); } timer = new Timer(TIMER_NAME, true); timer.schedule(new CleanupTimerTask(), startupOffset, period); }
From source file:de.thb.ue.backend.service.EvaluationService.java
License:Apache License
@Override public String add(int semester, int students, String tutor, int subject, SemesterType type, String revisionName) throws ParticipantException, EvaluationException { Subject subjectToEvaluate = subjectService.getByID(subject); List<Tutor> tutorsForEvaluation = tutorService.getByFamilyName(tutor); if (tutorsForEvaluation == null || tutorsForEvaluation.isEmpty()) { log.error("Tutor was unknown!"); }//from w ww.j a v a 2s . c o m String uid = UUID.randomUUID().toString(); QuestionRevision questionRevision = questionRevisionRepo.findByName(revisionName).get(0); Evaluation evaluation = evaluationRepo.save(new Evaluation(uid, LocalDateTime.now(), semester, tutorsForEvaluation, subjectToEvaluate, type, false, questionRevision, null, students, 0)); participantService.add(students, evaluation); return uid; }
From source file:de.tshw.worktracker.model.WorkLogEntry.java
License:MIT License
public WorkLogEntry() { super();/*ww w.ja v a2 s.c om*/ this.project = null; this.startTime = LocalDateTime.now(); this.endTime = null; this.comment = null; }
From source file:de.tshw.worktracker.model.WorkLogEntry.java
License:MIT License
public WorkLogEntry(Project project) { super();//from w w w . java 2 s . c o m this.project = project; this.startTime = LocalDateTime.now(); this.endTime = null; this.comment = null; }
From source file:de.tshw.worktracker.model.WorkLogEntry.java
License:MIT License
public void stop() { this.endTime = LocalDateTime.now(); }
From source file:de.tshw.worktracker.view.SimpleConsoleView.java
License:MIT License
@Override public void update(WorkTracker workTracker) { LocalDateTime startTime = workTracker.getCurrentLogEntry().getStartTime(); Period timeElapsed = new Period(startTime, LocalDateTime.now()); PeriodFormatter formatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d").appendPrefix(" ") .appendHours().appendSuffix("h").appendPrefix(" ").appendMinutes().appendSuffix("m") .appendPrefix(" ").appendSeconds().appendSuffix("s").toFormatter(); String formattedTimeElapsed = formatter.print(timeElapsed); if (formattedTimeElapsed.equals("")) { formattedTimeElapsed = " 0s"; }/* w w w . j a va 2s . c o m*/ System.out.print("\rCurrent Project: " + workTracker.getCurrentLogEntry().getProject() + " - Time elapsed: " + formattedTimeElapsed); }
From source file:de.tshw.worktracker.view.TimeEntriesTableModel.java
License:MIT License
public String update(WorkTracker workTracker) { int oldProjectCount = elapsedTimes.size(); HashMap<Project, MutablePeriod> newTimes = new HashMap<>(); for (Project p : workTracker.getProjects()) { newTimes.put(p, new MutablePeriod()); }//from w w w .jav a 2 s .c om MutablePeriod totalTimeToday = new MutablePeriod(); for (WorkLogEntry entry : workTracker.getTodaysWorkLogEntries()) { if (!newTimes.containsKey(entry.getProject())) { newTimes.put(entry.getProject(), new MutablePeriod()); } if (entry.getStartTime().toLocalDate().toDateTimeAtStartOfDay() .equals(LocalDate.now().toDateTimeAtStartOfDay())) { newTimes.get(entry.getProject()).add(entry.getTimeElapsed()); if (!entry.getProject().equals(workTracker.getPauseProject())) { totalTimeToday.add(entry.getTimeElapsed()); } } } WorkLogEntry entry = workTracker.getCurrentLogEntry(); Period period = new Period(entry.getStartTime(), LocalDateTime.now()); newTimes.get(entry.getProject()).add(period); if (!entry.getProject().equals(workTracker.getPauseProject())) { totalTimeToday.add(period); } for (Project p : newTimes.keySet()) { elapsedTimes.put(p, newTimes.get(p).toPeriod()); } this.totalTimeElapsedToday = totalTimeToday.toPeriod(); if (oldProjectCount == elapsedTimes.size()) { this.fireTableRowsUpdated(0, elapsedTimes.size()); } else { this.fireTableDataChanged(); } return periodFormatter.print(this.totalTimeElapsedToday.normalizedStandard()); }
From source file:fyp.hms.controller.AppointmentController.java
@RequestMapping(value = "/createApptment", params = "createApp", method = RequestMethod.GET) public String createApp(@RequestParam Map<String, String> parameters, ModelMap model, HttpSession session) throws ParseException { String customerId = (String) parameters.get("customerId"); String time = parameters.get("appointmentTime"); String apptDate = parameters.get("appointmentDate"); String hairStylistName = parameters.get("hairStylist"); String remarks = parameters.get("remarks"); String customerName = parameters.get("customerName"); String dob = parameters.get("dob"); String email = parameters.get("email"); String hairStylist = parameters.get("hairStylist"); String duration = parameters.get("duration"); //check empty fields (ps: remarks is allowed to be empty) if (parameters.get("customerId").length() == 0 || parameters.get("hairStylist").length() == 0 || parameters.get("appointmentDate").length() == 0 || parameters.get("customerName").length() == 0 || parameters.get("appointmentDate") == null || parameters.get("appointmentTime").length() == 0 || parameters.get("appointmentTime") == null || parameters.get("appointmentTime").equals("") || parameters.get("duration").length() == 0) { model.addAttribute("error", "Field(s) cannot be empty (except for remarks)."); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; }/*from w w w. ja v a 2s.c o m*/ //check the format of customer id int phoneNo = 0; try { phoneNo = Integer.parseInt(customerId); if (customerId.length() < 8) { model.addAttribute("error", "Phone number must contain at least 8 digits."); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; } } catch (NumberFormatException e) { model.addAttribute("error", "Invalid Customer Id"); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; } if (apptDate.length() != 10) { model.addAttribute("error", "Invalid appointment date."); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; } //retrieve customer based on customer id Customer cust = appointmentService.retrieveCust(phoneNo); if (cust == null) { model.addAttribute("error", "Customer Id doesn't exist."); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; } //convert util.date format to sql.date format SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date appointmentDate; java.sql.Date sqlDate = null; String strSqlDate = ""; try { appointmentDate = format.parse(apptDate); sqlDate = new java.sql.Date(appointmentDate.getTime()); strSqlDate = sqlDate + ""; } catch (ParseException ex) { model.addAttribute("error", "Invalid appointment date."); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; } //check if the appointment date is before the current date Date currentDate = new Date(); java.sql.Date sqlCurrentDate = new java.sql.Date(currentDate.getTime()); String strSqlCurrentDate = sqlCurrentDate + ""; if (!strSqlDate.equals(strSqlCurrentDate) && sqlDate.before(sqlCurrentDate)) { model.addAttribute("error", "Appointment Date needs to be after current date."); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; } //appointment time SimpleDateFormat timeDateFormat = new SimpleDateFormat("hh:mm"); long ms = timeDateFormat.parse(time).getTime(); int intDuration = Integer.parseInt(duration); long endMs = ms + (intDuration * 60000); Time t = new Time(ms); Time endTime = new Time(endMs); //get current time Calendar cal = Calendar.getInstance(); LocalDateTime localDateTime = LocalDateTime.now(); String localTime = localDateTime.toLocalTime() + ""; String strLocalTime = localTime.substring(0, 8); //String strCurrentTime = timeDateFormat.format(cal.getTime()); long currentMS = timeDateFormat.parse(strLocalTime).getTime(); Time currentTime = new Time(currentMS); //if appointment date is same as the current date if (strSqlDate.equals(strSqlCurrentDate)) { ////check if the appointment time is before the current time if (t.before(currentTime)) { model.addAttribute("error", "Appointment Time needs to be after current time."); model.addAttribute("customerId", customerId); model.addAttribute("time", time); model.addAttribute("apptDate", apptDate); model.addAttribute("hairStylistName", hairStylistName); model.addAttribute("remarks", remarks); model.addAttribute("customerName", customerName); model.addAttribute("dob", dob); model.addAttribute("email", email); model.addAttribute("hairStylist", hairStylist); model.addAttribute("duration", duration); return "addAppointment"; } } List<Appointment> apptList = appointmentService.retrieveAppointment(hairStylistName); /* if(apptList != null){ for(Appointment appt: apptList){ String strDate = appt.getAppointmentDate() + ""; if(strSqlDate.equals(strDate)){ Time apptTime = appt.getAppointmentTime(); Time apptEndTime = appt.getApptEndTime(); if(t.after(apptTime) && t.before(apptEndTime)){ model.addAttribute("error","The hairStylist has an appointment at this timing. Plese select another time."); model.addAttribute("customerId",customerId); model.addAttribute("time",time); model.addAttribute("apptDate",apptDate); model.addAttribute("hairStylistName",hairStylistName); model.addAttribute("remarks",remarks); model.addAttribute("customerName",customerName); model.addAttribute("dob",dob); model.addAttribute("email",email); model.addAttribute("hairStylist",hairStylist); model.addAttribute("duration",duration); return "addAppointment"; } String strAfterTime = t + ""; SimpleDateFormat dfAfter = new SimpleDateFormat("HH:mm"); Date afterDate = dfAfter.parse(strAfterTime); Calendar afterCal = Calendar.getInstance(); afterCal.setTime(afterDate); afterCal.add(Calendar.MINUTE, 60); String newAfterTime = dfAfter.format(afterCal.getTime()); long afterMS = dfAfter.parse(newAfterTime).getTime(); Time afterTime = new Time(afterMS); String strBeforeTime = t + ""; SimpleDateFormat dfBefore = new SimpleDateFormat("HH:mm"); Date beforeDate = dfBefore.parse(strBeforeTime); Calendar beforeCal = Calendar.getInstance(); beforeCal.setTime(beforeDate); beforeCal.add(Calendar.MINUTE, -60); String newBeforeTime = dfBefore.format(beforeCal.getTime()); long beforeMS = dfBefore.parse(newBeforeTime).getTime(); Time beforeTime = new Time(beforeMS); //Date beforeTime1 = beforeCal.getTime(); if(apptTime.after(beforeTime) && apptTime.before(afterTime)){ model.addAttribute("error","The hairStylist has an another appointment within 1 hour of this timing. Plese select another time."); model.addAttribute("customerId",customerId); model.addAttribute("time",time); model.addAttribute("apptDate",apptDate); model.addAttribute("hairStylistName",hairStylistName); model.addAttribute("remarks",remarks); model.addAttribute("customerName",customerName); model.addAttribute("dob",dob); model.addAttribute("email",email); model.addAttribute("hairStylist",hairStylist); model.addAttribute("duration",duration); return "addAppointment"; } } } }*/ boolean isAdded = appointmentService.addAppointment(phoneNo, hairStylistName, customerName, sqlDate, t, endTime, remarks, "Ongoing"); if (!isAdded) { model.addAttribute("error", "Appointment cannot be added."); } else { model.addAttribute("success", "Appointment has been added successfully."); } String username = (String) session.getAttribute("username"); String role = (String) session.getAttribute("role"); if (username != null && role != null) { if (role.equals("staff")) { apptList = appointmentService.retrieveAppointment(username); model.addAttribute("apptList", apptList); } else { apptList = appointmentService.retrieveAllAppointment(); model.addAttribute("apptList", apptList); } } return "appointment"; }
From source file:me.tongfei.progressbar.ProgressBar.java
License:Apache License
/** * Starts this progress bar. */ public ProgressBar start() { progress.startTime = LocalDateTime.now(); thread.start(); return this; }