List of usage examples for java.util Date getDate
@Deprecated public int getDate()
From source file:com.android.mms.ui.MessageUtils.java
public static boolean shouldShowTimeDivider(long curTime, long nextTime) { Date curDate = new Date(curTime); Date nextDate = new Date(nextTime); Date cur = new Date(curDate.getYear(), curDate.getMonth(), curDate.getDate(), 0, 0, 0); Date next = new Date(nextDate.getYear(), nextDate.getMonth(), nextDate.getDate(), 0, 0, 0); return (cur.getTime() != next.getTime()); }
From source file:com.homeworkreminder.Main.java
@SuppressWarnings("deprecation") private void initCalendarPage() { lastSelectedCalendarDate = Calendar.getInstance().getTime(); calView = this.inflater.inflate(R.layout.calendar, main_content, false); if (caldroidFragment == null) { caldroidFragment = new CaldroidFragment(); Bundle args = new Bundle(); Calendar cal = Calendar.getInstance(); args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1); args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR)); args.putBoolean(CaldroidFragment.ENABLE_SWIPE, true); args.putBoolean(CaldroidFragment.SIX_WEEKS_IN_CALENDAR, true); caldroidFragment.setArguments(args); }/* w w w . j av a2 s. c o m*/ caldroidFragment.setBackgroundResourceForDate(R.color.bg_blue, Calendar.getInstance().getTime()); caldroidFragment.setTextColorForDate(R.color.pure_white, Calendar.getInstance().getTime()); info_list = (ListView) calView.findViewById(R.id.info_listview); main_content.addView(calView); FragmentTransaction t = getSupportFragmentManager().beginTransaction(); t.replace(R.id.calendar_container, caldroidFragment); t.commit(); tv_calendar_notaskfordate = (TextView) findViewById(R.id.tv_calendar_notaskfordate); final CaldroidListener listener = new CaldroidListener() { @Override public void onSelectDate(Date date, View view) { initInfoListForDate(date); Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, date.getYear() + 1900); c.set(Calendar.MONTH, date.getMonth()); c.set(Calendar.DAY_OF_MONTH, date.getDate()); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); Calendar r = Calendar.getInstance(); r.set(Calendar.YEAR, lastSelectedCalendarDate.getYear() + 1900); r.set(Calendar.MONTH, lastSelectedCalendarDate.getMonth()); r.set(Calendar.DAY_OF_MONTH, lastSelectedCalendarDate.getDate()); r.set(Calendar.HOUR_OF_DAY, 0); r.set(Calendar.MINUTE, 0); r.set(Calendar.SECOND, 0); r.set(Calendar.MILLISECOND, 0); if (c.get(Calendar.MONTH) != currCalendarMonth.get(Calendar.MONTH)) { caldroidFragment.setBackgroundResourceForDate(R.drawable.border_bg, date); caldroidFragment.setTextColorForDate(R.color.caldroid_gray, date); } else { if (TaskMap.containsKey(c) && !TaskMap.get(c).isEmpty()) { caldroidFragment.setTextColorForDate(R.color.pure_white, date); caldroidFragment.setBackgroundResourceForDate(R.drawable.border_bg_green, date); } else { caldroidFragment.setBackgroundResourceForDate(R.drawable.border_bg, date); caldroidFragment.setTextColorForDate(R.color.black, date); } } if (r.get(Calendar.MONTH) != currCalendarMonth.get(Calendar.MONTH)) { caldroidFragment.setBackgroundResourceForDate(R.color.pure_white, lastSelectedCalendarDate); caldroidFragment.setTextColorForDate(R.color.caldroid_gray, lastSelectedCalendarDate); } else { if (TaskMap.containsKey(r) && !TaskMap.get(r).isEmpty()) { caldroidFragment.setTextColorForDate(R.color.pure_white, lastSelectedCalendarDate); caldroidFragment.setBackgroundResourceForDate(R.color.bg_green, lastSelectedCalendarDate); } else { caldroidFragment.setBackgroundResourceForDate(R.color.pure_white, lastSelectedCalendarDate); caldroidFragment.setTextColorForDate(R.color.black, lastSelectedCalendarDate); } } lastSelectedCalendarDate = new Date(date.getTime()); caldroidFragment.setBackgroundResourceForDate(R.color.bg_blue, Calendar.getInstance().getTime()); caldroidFragment.setTextColorForDate(R.color.pure_white, Calendar.getInstance().getTime()); caldroidFragment.refreshView(); } @Override public void onChangeMonth(int month, int year) { month--; currCalendarMonth.set(Calendar.MONTH, month); currCalendarMonth.set(Calendar.YEAR, year); Calendar v = Calendar.getInstance(); v.set(Calendar.YEAR, lastSelectedCalendarDate.getYear() + 1900); v.set(Calendar.MONTH, lastSelectedCalendarDate.getMonth()); v.set(Calendar.DAY_OF_MONTH, lastSelectedCalendarDate.getDate()); v.set(Calendar.HOUR_OF_DAY, 0); v.set(Calendar.MINUTE, 0); v.set(Calendar.SECOND, 0); v.set(Calendar.MILLISECOND, 0); if (v.get(Calendar.MONTH) != month) { caldroidFragment.setBackgroundResourceForDate(R.color.pure_white, lastSelectedCalendarDate); caldroidFragment.setTextColorForDate(R.color.caldroid_gray, lastSelectedCalendarDate); } else { if (TaskMap.containsKey(v)) { caldroidFragment.setTextColorForDate(R.color.pure_white, lastSelectedCalendarDate); caldroidFragment.setBackgroundResourceForDate(R.color.bg_green, lastSelectedCalendarDate); } else { caldroidFragment.setBackgroundResourceForDate(R.color.pure_white, lastSelectedCalendarDate); caldroidFragment.setTextColorForDate(R.color.black, lastSelectedCalendarDate); } } Calendar k = Calendar.getInstance(); k.set(Calendar.DAY_OF_MONTH, 1); k.set(Calendar.YEAR, year); k.set(Calendar.MONTH, month); Calendar prev = Calendar.getInstance(); Calendar nxt = Calendar.getInstance(); prev.set(Calendar.YEAR, k.get(Calendar.YEAR)); nxt.set(Calendar.YEAR, k.get(Calendar.YEAR)); prev.set(Calendar.MONTH, k.get(Calendar.MONTH) - 1); nxt.set(Calendar.MONTH, k.get(Calendar.MONTH) + 1); prev.set(Calendar.DAY_OF_MONTH, 1); int prev_month = prev.get(Calendar.MONTH); nxt.set(Calendar.DAY_OF_MONTH, 1); int nxt_month = nxt.get(Calendar.MONTH); while (k.get(Calendar.MONTH) == month) { caldroidFragment.setBackgroundResourceForDate(R.color.pure_white, k.getTime()); caldroidFragment.setTextColorForDate(R.color.black, k.getTime()); k.add(Calendar.DAY_OF_MONTH, 1); } while (prev.get(Calendar.MONTH) == prev_month) { caldroidFragment.setBackgroundResourceForDate(R.color.pure_white, prev.getTime()); caldroidFragment.setTextColorForDate(R.color.caldroid_gray, prev.getTime()); prev.add(Calendar.DAY_OF_MONTH, 1); } while (nxt.get(Calendar.MONTH) == nxt_month) { caldroidFragment.setBackgroundResourceForDate(R.color.pure_white, nxt.getTime()); caldroidFragment.setTextColorForDate(R.color.caldroid_gray, nxt.getTime()); nxt.add(Calendar.DAY_OF_MONTH, 1); } setCalendarTaskForMonth(month, year); Date r = new Date(year - 1900, month, 1, 0, 0, 0); if (initInfoListForDate(r)) { caldroidFragment.setTextColorForDate(R.color.pure_white, r); caldroidFragment.setBackgroundResourceForDate(R.drawable.border_bg_green, r); } else { caldroidFragment.setBackgroundResourceForDate(R.drawable.border_bg, r); caldroidFragment.setTextColorForDate(R.color.black, r); } lastSelectedCalendarDate = (Date) r.clone(); caldroidFragment.setBackgroundResourceForDate(R.color.bg_blue, Calendar.getInstance().getTime()); caldroidFragment.setTextColorForDate(R.color.pure_white, Calendar.getInstance().getTime()); caldroidFragment.refreshView(); } @Override public void onLongClickDate(Date date, View view) { } @Override public void onCaldroidViewCreated() { } }; caldroidFragment.setCaldroidListener(listener); caldroidFragment.setBackgroundResourceForDate(R.color.bg_blue, Calendar.getInstance().getTime()); caldroidFragment.setTextColorForDate(R.color.pure_white, Calendar.getInstance().getTime()); setCalendarTaskForMonth(Calendar.getInstance().get(Calendar.MONTH), Calendar.getInstance().get(Calendar.YEAR)); }
From source file:org.sakaiproject.myshowcase.logic.MyShowcaseService.java
public String formattedLongDate(Date date) { return ordinalOfInteger(date.getDate()) + " " + monthName(date.getMonth() + 1) + " " + (1900 + date.getYear());/*from w ww .j a v a 2s . c o m*/ }
From source file:org.hil.vaccinationday.service.impl.VaccinationDayManagerImpl.java
public void updateChildrenVaccinationDay(VaccinationDay vDay) { List<Children> listChildren = childrenDaoExt.findByCommuneAndFinishedAndLocked(vDay.getCommune(), false, false);/*w w w. j a v a 2 s . c o m*/ log.debug("List update: " + listChildren.size()); if (listChildren == null || listChildren.size() == 0) return; for (Children c : listChildren) { List<ChildrenVaccinationHistory> listVaccinationPending = childrenVaccinationHistoryDaoExt .findByChildAndVaccinatedAndOderbyVaccinationId(c, (short) 0, true); List<ChildrenVaccinationHistory> listFinishedVaccinations = childrenVaccinationHistoryDaoExt .findByChildAndVaccinatedAndOderbyVaccinationId(c, (short) 1, true); Date prevDueDate = null; log.debug("************Done: " + listFinishedVaccinations.size() + " Pending: " + listVaccinationPending.size()); if (listFinishedVaccinations != null && listFinishedVaccinations.size() > 0) { prevDueDate = listFinishedVaccinations.get(listFinishedVaccinations.size() - 1) .getDateOfImmunization(); } log.debug("************DIM: " + vDay.getDateInMonth()); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String strDueDate = ""; Date dueDate = null; Integer dateInMonth = vDay.getDateInMonth(); Date today = new Date(); Integer currentMonth = today.getMonth() + 1; Integer currentYear = today.getYear() + 1900; for (int i = 0; i < listVaccinationPending.size(); i++) { ChildrenVaccinationHistory vaccinationHistory = listVaccinationPending.get(i); Vaccination vaccination = vaccinationHistory.getVaccination(); if (vaccination.getId() > 1) { Calendar recommendedTime = Calendar.getInstance(); recommendedTime.setTime(c.getDateOfBirth()); Integer deltaDate = vaccination.getAgeUnit() == 0 ? 0 : vaccination.getAge() * 30; recommendedTime.add(Calendar.DATE, deltaDate); Integer deltaYear = 0; Integer dueMonth = 0; Integer dueYear = 0; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; try { boolean overCall = false; if (vaccination.getLimitDays() != null && vaccination.getLimitDays() > 0) { Calendar c2 = Calendar.getInstance(); c2.setTime(c.getDateOfBirth()); c2.add(Calendar.DATE, vaccination.getLimitDays()); if (c2.getTime().getTime() < today.getTime()) { vaccinationHistory.setVaccinated((short) 3); vaccinationHistory.setDateOfImmunization(recommendedTime.getTime()); overCall = true; } } if (!overCall) { if (prevDueDate == null) { if (recommendedTime.getTime().getTime() >= today.getTime()) { if (recommendedTime.getTime().getYear() == today.getYear()) { if (recommendedTime.getTime().getMonth() == today.getMonth()) { if (dateInMonth >= recommendedTime.getTime().getDate()) { dueYear = recommendedTime.getTime().getYear() + 1900; dueMonth = recommendedTime.getTime().getMonth() + 1; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = recommendedTime.getTime().getMonth() + 1 + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = currentYear + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } } else { if (dateInMonth >= recommendedTime.getTime().getDate()) { dueYear = recommendedTime.getTime().getYear() + 1900; dueMonth = recommendedTime.getTime().getMonth() + 1; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = recommendedTime.getTime().getMonth() + 1 + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = currentYear + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } } } else { if (dateInMonth >= recommendedTime.getTime().getDate()) { dueYear = recommendedTime.getTime().getYear() + 1900; dueMonth = recommendedTime.getTime().getMonth() + 1; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = recommendedTime.getTime().getMonth() + 1 + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = recommendedTime.getTime().getYear() + 1900 + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } } dueDate = format.parse(strDueDate); vaccinationHistory.setDateOfImmunization(dueDate); } else { if (dateInMonth >= today.getDate()) { dueYear = currentYear; dueMonth = currentMonth; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = currentMonth + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = currentYear + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } dueDate = format.parse(strDueDate); vaccinationHistory.setDateOfImmunization(dueDate); } prevDueDate = dueDate; } else { Calendar gapTime = Calendar.getInstance(); gapTime.setTime(prevDueDate); Integer deltaGapDate = vaccination.getGap() > 0 ? vaccination.getGap() : 0; gapTime.add(Calendar.DATE, deltaGapDate); if (recommendedTime.getTime().getTime() < gapTime.getTime().getTime()) { recommendedTime = gapTime; } if (recommendedTime.getTime().getTime() >= today.getTime()) { if (recommendedTime.getTime().getYear() == today.getYear()) { if (recommendedTime.getTime().getMonth() == today.getMonth()) { if (dateInMonth >= recommendedTime.getTime().getDate()) { dueYear = recommendedTime.getTime().getYear() + 1900; dueMonth = recommendedTime.getTime().getMonth() + 1; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = recommendedTime.getTime().getMonth() + 1 + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = currentYear + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } } else { if (dateInMonth >= recommendedTime.getTime().getDate()) { dueYear = recommendedTime.getTime().getYear() + 1900; dueMonth = recommendedTime.getTime().getMonth() + 1; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = recommendedTime.getTime().getMonth() + 1 + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = currentYear + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } } } else { if (dateInMonth >= recommendedTime.getTime().getDate()) { dueYear = recommendedTime.getTime().getYear() + 1900; dueMonth = recommendedTime.getTime().getMonth() + 1; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = recommendedTime.getTime().getMonth() + 1 + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = recommendedTime.getTime().getYear() + 1900 + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } } dueDate = format.parse(strDueDate); vaccinationHistory.setDateOfImmunization(dueDate); } else { if (dateInMonth >= today.getDate()) { dueYear = currentYear; dueMonth = currentMonth; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } else { dueMonth = currentMonth + 1; deltaYear = dueMonth / 12; dueMonth = dueMonth % 12; dueYear = currentYear + deltaYear; strDueDate = dueYear + "-" + dueMonth + "-" + dateInMonth; } dueDate = format.parse(strDueDate); vaccinationHistory.setDateOfImmunization(dueDate); } prevDueDate = dueDate; } } childrenVaccinationHistoryDao.save(vaccinationHistory); } catch (ParseException e) { e.printStackTrace(); } } } } }
From source file:com.mimp.controllers.personal.java
@RequestMapping(value = "/logPersonalFiltroHoy", method = RequestMethod.GET) public ModelAndView logPersonalFiltroHoy_GET(ModelMap map, HttpSession session) { Personal usuario = (Personal) session.getAttribute("usuario"); if (usuario == null) { String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente"; map.addAttribute("mensaje", mensaje); return new ModelAndView("login", map); }/*from w w w . ja va2 s. c o m*/ //List<Personal> lista = Servicio.listaPersonal(); Date diatemp = new Date(); String dia = String.valueOf(diatemp.getDate()) + "/" + String.valueOf(diatemp.getMonth() + 1) + "/" + String.valueOf(diatemp.getYear() + 1900); map.put("listaPersonalLog", ServicioPersonal.getLogPersonalPorDia(dia)); map.put("dia", dia); return new ModelAndView("/Personal/registros/usuarios/log_personal", map); }
From source file:com.mimp.controllers.personal.java
@RequestMapping(value = "/logParticularFiltroHoy", method = RequestMethod.GET) public ModelAndView logParticularFiltroHoy_GET(ModelMap map, HttpSession session) { Personal usuario = (Personal) session.getAttribute("usuario"); if (usuario == null) { String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente"; map.addAttribute("mensaje", mensaje); return new ModelAndView("login", map); }// ww w. j a va2 s .c o m long idpersonal = Long.parseLong(session.getAttribute("id").toString()); //List<Personal> lista = Servicio.listaPersonal(); Date diatemp = new Date(); String dia = String.valueOf(diatemp.getDate()) + "/" + String.valueOf(diatemp.getMonth() + 1) + "/" + String.valueOf(diatemp.getYear() + 1900); Personal personal = new Personal(); personal = ServicioPersonal.getPersonal(idpersonal); map.put("listaParticularLog", ServicioPersonal.getLogParticularPorDia(idpersonal, dia)); map.put("user", personal); map.put("dia", dia); return new ModelAndView("/Personal/registros/usuarios/log_particular", map); }
From source file:com.mss.msp.util.DataSourceDataProvider.java
public String createFileInFileSystem(String filePath, String fileName, File file, String privateKey) throws Exception { File theFile = null;/*from w w w .j a v a 2 s.c om*/ try { File createPath = new File(filePath); Date dt = new Date(); /* The month is generated from here */ String month = ""; if (dt.getMonth() == 0) { month = "Jan"; } else if (dt.getMonth() == 1) { month = "Feb"; } else if (dt.getMonth() == 2) { month = "Mar"; } else if (dt.getMonth() == 3) { month = "Apr"; } else if (dt.getMonth() == 4) { month = "May"; } else if (dt.getMonth() == 5) { month = "Jun"; } else if (dt.getMonth() == 6) { month = "Jul"; } else if (dt.getMonth() == 7) { month = "Aug"; } else if (dt.getMonth() == 8) { month = "Sep"; } else if (dt.getMonth() == 9) { month = "Oct"; } else if (dt.getMonth() == 10) { month = "Nov"; } else if (dt.getMonth() == 11) { month = "Dec"; } short week = (short) (Math.round(dt.getDate() / 7)); // createPath = new File(createPath.getAbsolutePath() + "/" + // String.valueOf(dt.getYear() + 1900) + "/" + month + "/" + // String.valueOf(week)); createPath = new File( createPath.getAbsolutePath() + File.separator + String.valueOf(dt.getYear() + 1900) + File.separator + month + File.separator + String.valueOf(week)); createPath.mkdirs(); /* * here it takes the absolute path and the name of the file that is * to be uploaded */ theFile = new File(createPath.getAbsolutePath()); // setConsultantResumeFilePath(theFile.toString()); /* copies the file to the destination */ // File destFile = new File(theFile + File.separator + filePath); // System.out.println("fileName--->"+fileName); File destFile = new File(theFile + File.separator + fileName); String aesKeyString = Properties.getProperty("AES_KEY"); // System.out.println("filePath--->"+filePath); // System.out.println("privateKey--"+privateKey); // privateKey="LaIIBJuQfjfFrPUrj+rgwg=="; // System.out.println("privateKey after--"+privateKey); SecurityServiceProvider.encryptFileUsingAES(aesKeyString, file, destFile); // System.out.println("theFile.toString()--->"+theFile.toString()); } catch (Exception ex) { ex.printStackTrace(); System.out.println("Error in Catch of createFileInFileSystem --->" + ex.getMessage()); // TODO: handle exception } // FileUtils.copyFile(file, destFile); return theFile.toString(); }
From source file:ca.oson.json.Oson.java
private <E> Date json2DateDefault(FieldData objectDTO) { if (getDefaultType() == JSON_INCLUDE.DEFAULT || objectDTO.required()) { Date defaultValue = (Date) objectDTO.getDefaultValue(); if (defaultValue != null) { return defaultValue; }//w w w.j av a 2 s . c o m return DefaultValue.getDate(); } return null; }