List of usage examples for java.util Date getYear
@Deprecated public int getYear()
From source file:org.springframework.extensions.webscripts.json.JSONUtils.java
/** * Convert value to JSON string//from w w w .j a v a 2 s. c o m * * @param value Java object value * @param writer JSONWriter for output stream * @throws IOException */ private void valueToJSONString(Object value, JSONWriter writer) throws IOException { if (value instanceof IdScriptableObject && TYPE_DATE.equals(((IdScriptableObject) value).getClassName())) { Date date = (Date) Context.jsToJava(value, Date.class); // Build the JSON object to represent the UTC date writer.startObject().writeValue("zone", "UTC").writeValue("year", date.getYear()) .writeValue("month", date.getMonth()).writeValue("date", date.getDate()) .writeValue("hours", date.getHours()).writeValue("minutes", date.getMinutes()) .writeValue("seconds", date.getSeconds()).writeValue("milliseconds", date.getTime()) .endObject(); } else if (value instanceof NativeJavaObject) { // extract the underlying Java object and recursively output Object javaValue = Context.jsToJava(value, Object.class); valueToJSONString(javaValue, writer); } else if (value instanceof NativeArray) { // Output the native object nativeArrayToJSONString((NativeArray) value, writer); } else if (value instanceof NativeObject) { // Output the native array nativeObjectToJSONString((NativeObject) value, writer); } else if (value instanceof Number) { if (value instanceof Integer || value instanceof Long) { writer.writeValue(((Number) value).longValue()); } else if (value instanceof Double) { writer.writeValue(((Number) value).doubleValue()); } else if (value instanceof Float) { writer.writeValue(((Number) value).floatValue()); } else { writer.writeValue(((Number) value).doubleValue()); } } else if (value instanceof Boolean) { writer.writeValue(((Boolean) value).booleanValue()); } else if (value instanceof Map) { writer.startObject(); for (Object key : ((Map) value).keySet()) { writer.startValue(key.toString()); valueToJSONString(((Map) value).get(key), writer); writer.endValue(); } writer.endObject(); } else if (value instanceof List) { writer.startArray(); for (Object val : (List) value) { valueToJSONString(val, writer); } writer.endArray(); } else if (value != null) { writer.writeValue(value.toString()); } else { writer.writeNullValue(); } }
From source file:TimeFormatter.java
/** * Format the given date as a string, according to the given * format string.//from w w w . ja v a 2s .c om * The format string is of the form used by the strftime(3) UNIX * call. * @param date The date to format * @param format The formatting string * @return the String with the formatted date. */ public static String format(Date date, String format) { StringBuffer buf = new StringBuffer(50); char ch; for (int i = 0; i < format.length(); i++) { ch = format.charAt(i); if (ch == '%') { ++i; if (i == format.length()) break; ch = format.charAt(i); if (ch == 'E') { // Alternate Era ++i; } else if (ch == 'Q') { // Alternate numeric symbols ++i; } if (i == format.length()) break; ch = format.charAt(i); switch (ch) { case 'A': buf.append(fullWeekDays[date.getDay()]); break; case 'a': buf.append(abrWeekDays[date.getDay()]); break; case 'B': buf.append(fullMonths[date.getMonth()]); break; case 'b': case 'h': buf.append(abrMonths[date.getMonth()]); break; case 'C': appendPadded(buf, (date.getYear() + 1900) / 100, 2); break; case 'c': buf.append(date.toLocaleString()); break; case 'D': buf.append(TimeFormatter.format(date, "%m/%d/%y")); break; case 'd': appendPadded(buf, date.getDate(), 2); break; case 'e': appendPadded(buf, date.getMonth() + 1, 2, ' '); break; case 'H': appendPadded(buf, date.getHours(), 2); break; case 'I': case 'l': int a = date.getHours() % 12; if (a == 0) a = 12; appendPadded(buf, a, 2, ch == 'I' ? '0' : ' '); break; case 'j': buf.append("[?]"); // No simple way to get this as of now break; case 'k': appendPadded(buf, date.getHours(), 2, ' '); break; case 'M': appendPadded(buf, date.getMinutes(), 2); break; case 'm': appendPadded(buf, date.getMonth() + 1, 2); break; case 'n': buf.append('\n'); break; case 'p': buf.append(date.getHours() < 12 ? "am" : "pm"); break; case 'R': buf.append(TimeFormatter.format(date, "%H:%M")); break; case 'r': buf.append(TimeFormatter.format(date, "%l:%M%p")); break; case 'S': appendPadded(buf, date.getSeconds(), 2); break; case 'T': buf.append(TimeFormatter.format(date, "%H:%M:%S")); break; case 't': buf.append('\t'); break; case 'U': case 'u': case 'V': case 'W': buf.append("[?]"); // Weekdays are a pain, especially // without day of year (0-365) ; break; case 'w': buf.append(date.getDay()); break; case 'X': buf.append(TimeFormatter.format(date, "%H:%M:%S")); break; case 'x': buf.append(TimeFormatter.format(date, "%B %e, %Y")); break; case 'y': appendPadded(buf, (date.getYear() + 1900) % 100, 2); break; case 'Y': appendPadded(buf, (date.getYear() + 1900), 4); break; case 'Z': String strdate = date.toString(); buf.append(strdate.substring(20, 23)); // (!) // There should be a better way // to do this... break; case '%': buf.append('%'); break; } } else { buf.append(ch); } } return buf.toString(); }
From source file:org.hil.vaccinationday.service.impl.VaccinationDayManagerImpl.java
public void updateChildrenVaccinationDay(VaccinationDay vDay) { List<Children> listChildren = childrenDaoExt.findByCommuneAndFinishedAndLocked(vDay.getCommune(), false, false);/*from www .j av a 2s . 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:org.commoncrawl.mapred.pipelineV3.domainmeta.blogs.postfrequency.ScanDatabaseStep.java
@Override public void map(TextBytes key, TextBytes jsonMetadata, OutputCollector<TextBytes, HitsByMonth> collector, Reporter reporter) throws IOException { String url = key.toString();/* w w w . j a v a 2s .c o m*/ Matcher topLevelMatcher = topLevelBlogPattern.matcher(url); Matcher nestedBlogMatcher = nestedBlogPattern.matcher(url); Matcher indexHTMLBlogMatcher = indexHTMLBlogPattern.matcher(url); Matcher indexBlogMatcher = indexBlogPattern.matcher(url); Matcher nestedIndexHTMLBlogMatcher = nestedIndexHTMLBlogPattern.matcher(url); Matcher nestedIndexBlogMatcher = nestedIndexBlogPattern.matcher(url); Matcher tumblrPostMatcher = tumblrStyleBlogPattern.matcher(url); if (indexHTMLBlogMatcher.matches() && indexHTMLBlogMatcher.groupCount() >= 1) { reporter.incrCounter(Counters.MATCHED_INDEX_HTML_PATTERN, 1); HitsByMonth hits = new HitsByMonth(); hits.setFlags(PostFrequencyInfo.Flags.HAS_INDEX_HTML_AFTER_DATE); collector.collect(new TextBytes("http://" + indexHTMLBlogMatcher.group(1) + "/"), hits); } else if (indexBlogMatcher.matches() && indexBlogMatcher.groupCount() >= 1) { reporter.incrCounter(Counters.MATCHED_INDEX_PATTERN, 1); HitsByMonth hits = new HitsByMonth(); hits.setFlags(PostFrequencyInfo.Flags.HAS_YEAR_MONTH_SLASH_INDEX); collector.collect(new TextBytes("http://" + indexBlogMatcher.group(1) + "/"), hits); } else if (nestedIndexHTMLBlogMatcher.matches() && nestedIndexHTMLBlogMatcher.groupCount() >= 2) { reporter.incrCounter(Counters.MATCHED_NESTED_INDEX_HTML_PATTERN, 1); HitsByMonth hits = new HitsByMonth(); hits.setFlags(PostFrequencyInfo.Flags.HAS_INDEX_HTML_AFTER_DATE); collector.collect(new TextBytes("http://" + nestedIndexHTMLBlogMatcher.group(1) + "/" + nestedIndexHTMLBlogMatcher.group(2) + "/"), hits); } else if (nestedIndexBlogMatcher.matches() && nestedIndexBlogMatcher.groupCount() >= 2) { reporter.incrCounter(Counters.MATCHED_NESTED_INDEX_PATTERN, 1); HitsByMonth hits = new HitsByMonth(); hits.setFlags(PostFrequencyInfo.Flags.HAS_YEAR_MONTH_SLASH_INDEX); collector.collect(new TextBytes( "http://" + nestedIndexBlogMatcher.group(1) + "/" + nestedIndexBlogMatcher.group(2) + "/"), hits); } else if (tumblrPostMatcher.matches() && tumblrPostMatcher.groupCount() >= 2) { reporter.incrCounter(Counters.MATCHED_TUMBLR_BLOG_POST_PATTERN, 1); String uniqueURL = new String("http://" + tumblrPostMatcher.group(1) + "/"); try { // HACK long postId = Long.parseLong(tumblrPostMatcher.group(2)); long relativeMonth = postId / 1000000000L; Date dateStart = new Date(110, 6, 1); Date dateOfPost = new Date(dateStart.getTime() + (relativeMonth * 30 * 24 * 60 * 60 * 1000)); HitsByMonth hits = new HitsByMonth(); hits.setHitCount(1); hits.setYear(dateOfPost.getYear() + 1900); hits.setMonth(dateOfPost.getMonth() + 1); collector.collect(new TextBytes(uniqueURL), hits); } catch (Exception e) { reporter.incrCounter(Counters.CAUGHT_EXCEPTION_DURING_TUMBLR_POST_PARSE, 1); LOG.error("Exception parsing url:" + url + " Exception:" + StringUtils.stringifyException(e)); } } else if (topLevelMatcher.matches() && topLevelMatcher.groupCount() >= 3) { reporter.incrCounter(Counters.MATCHED_TOP_LEVEL_POST_PATTERN, 1); String uniqueURL = new String("http://" + topLevelMatcher.group(1) + "/"); int year = Integer.parseInt(topLevelMatcher.group(2)); int month = Integer.parseInt(topLevelMatcher.group(3)); HitsByMonth hits = new HitsByMonth(); hits.setHitCount(1); hits.setYear(year); hits.setMonth(month); hits.setFlags(scanForGenerator(key, jsonMetadata, reporter)); collector.collect(new TextBytes(uniqueURL), hits); } else if (nestedBlogMatcher.matches() && nestedBlogMatcher.groupCount() >= 4) { reporter.incrCounter(Counters.MATCHED_NESTED_POST_PATTERN, 1); if (!nestedBlogMatcher.group(1).endsWith("tumblr.com")) { String uniqueURL = new String( "http://" + nestedBlogMatcher.group(1) + "/" + nestedBlogMatcher.group(2) + "/"); int year = Integer.parseInt(nestedBlogMatcher.group(3)); int month = Integer.parseInt(nestedBlogMatcher.group(4)); HitsByMonth hits = new HitsByMonth(); hits.setHitCount(1); hits.setYear(year); hits.setMonth(month); hits.setFlags(scanForGenerator(key, jsonMetadata, reporter)); collector.collect(new TextBytes(uniqueURL), hits); } } }
From source file:at.flack.MailMainActivity.java
public String getDate(Date date) { Date today = new Date(System.currentTimeMillis()); if (date.getDate() == today.getDate() && date.getMonth() == today.getMonth() && date.getYear() == today.getYear()) return new SimpleDateFormat("HH:mm", Locale.getDefault()).format(date); else//from w w w . j a v a 2 s . c o m return new SimpleDateFormat("dd. MMM", Locale.getDefault()).format(date); }
From source file:eionet.util.Util.java
/** * * @param timestamp Milliseconds since 1 January 1970. *//* w w w. jav a 2s. com*/ public static String pdfDate(long timestamp) { Date date = new Date(timestamp); String year = String.valueOf(1900 + date.getYear()); String month = String.valueOf(date.getMonth() + 1); month = (month.length() < 2) ? ("0" + month) : month; String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; return day + "/" + month + "/" + year; }
From source file:org.amnesty.aidoc.search.AidocSearch.java
private StringBuffer buildStandardQuery(StringBuffer query, Map<String, List<String>> queryMap, String language) {/* w ww. ja v a 2s . c o m*/ // Our query template. Prioritize new content. String tpl = "(" + "(" + "(@cm\\:title:(terms)^8 OR @cm\\:description:(terms)^4 OR TEXT:(terms))" + " AND @cm\\:from:[primRange]" + ") OR " // + "(" // + "(@cm\\:title:(terms)^8 OR @cm\\:description:(terms)^4 OR TEXT:(terms))" // + " AND @cm\\:from:[secRange]" // + ")^2 OR " + "(@cm\\:title:(terms)^8 OR @cm\\:description:(terms)^4 OR TEXT:(terms))" + ")" + ")"; Date from = new Date(); from.setYear(from.getYear() - 2); String primRange = ISO8601DateFormat.format(from) + " TO " + ISO8601DateFormat.format(new Date()); // from.setYear(from.getYear() - 4); // String secRange = ISO8601DateFormat.format(from) + " TO " // + ISO8601DateFormat.format(new Date()); // Compile regular expression Pattern pattern = Pattern.compile("primRange"); Matcher matcher = pattern.matcher(tpl); tpl = matcher.replaceAll(primRange); // pattern = Pattern.compile("secRange"); // matcher = pattern.matcher(tpl); // tpl = matcher.replaceAll(secRange); /* Process categories */ if (queryMap.containsKey("category")) { List<String> catValues = (List<String>) queryMap.get("category"); for (String category : catValues) { logger.debug("Search category: " + category); category = category.replace(" ", "_x0020_"); category = category.replace(",", "_x002c_"); query.append(" PATH:\"/cm:generalclassifiable//cm:" + category + "//*\" AND "); } } if (queryMap.containsKey("cat")) { List<String> catValues = (List<String>) queryMap.get("cat"); for (String category : catValues) { if (CategoryToClassMap.hm.containsKey(category.toUpperCase())) { String mappedClass = (String) CategoryToClassMap.hm.get(category.toUpperCase()); logger.debug("Mapping " + category + " to class: " + mappedClass); query.append(" @aicore\\:aiIndex:\""); query.append(mappedClass + "*"); query.append("\" AND"); } else logger.debug("No AiClass found for: " + category); } } /* Process keywords */ if (queryMap.containsKey("keywords")) { List<String> keywords = (List<String>) queryMap.get("keywords"); pattern = Pattern.compile("terms"); matcher = pattern.matcher(tpl); if (keywords.size() == 1) tpl = matcher.replaceAll(keywords.get(0)); else if (keywords.size() == 0) tpl = matcher.replaceAll("?"); else tpl = matcher.replaceAll("bad query"); query.append(tpl); } return query; }
From source file:eionet.util.Util.java
/** * A method for formatting the given timestamp into a String for history. * * @param timestamp Milliseconds since 1 January 1970. * @return formatted time as string in the form 2015/04/18 12:43. *//*from www. j a v a 2 s. c om*/ public static String historyDate(long timestamp) { Date date = new Date(timestamp); String year = String.valueOf(1900 + date.getYear()); String month = String.valueOf(date.getMonth() + 1); month = (month.length() < 2) ? ("0" + month) : month; String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; String hours = String.valueOf(date.getHours()); hours = (hours.length() < 2) ? ("0" + hours) : hours; String minutes = String.valueOf(date.getMinutes()); minutes = (minutes.length() < 2) ? ("0" + minutes) : minutes; String seconds = String.valueOf(date.getSeconds()); seconds = (seconds.length() < 2) ? ("0" + seconds) : seconds; String time = year; time = time + "/" + month; time = time + "/" + day; time = time + " " + hours; time = time + ":" + minutes; return time; }
From source file:eionet.util.Util.java
/** * A method for formatting the given timestamp into a String released_datasets.jsp. * * @param timestamp Milliseconds since 1 January 1970. *//*from ww w .j a v a 2s. c o m*/ private static String releasedDate(long timestamp, boolean shortMonth) { Date date = new Date(timestamp); String year = String.valueOf(1900 + date.getYear()); String month = String.valueOf(date.getMonth()); String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; Hashtable months = new Hashtable(); months.put("0", "January"); months.put("1", "February"); months.put("2", "March"); months.put("3", "April"); months.put("4", "May"); months.put("5", "June"); months.put("6", "July"); months.put("7", "August"); months.put("8", "September"); months.put("9", "October"); months.put("10", "November"); months.put("11", "December"); String time = day + " " + (shortMonth ? months.get(month).toString().substring(0, 3) : months.get(month)) + " " + year; return time; }
From source file:org.openmrs.module.vcttrac.web.controller.VCTTracnetIndicatorsController.java
/** * Auto generated method comment/*w w w . ja v a2 s. co m*/ * * @param request * @param response * @param mav */ private void mapParameters(HttpServletRequest request, HttpServletResponse response, ModelAndView mav) { DateFormat df = Context.getDateFormat(); try { Date today = new Date(); if (request.getParameter("location") == null || request.getParameter("location").compareTo("") == 0) mav.addObject("defaultLoc", VCTConfigurationUtil.getDefaultLocationId()); else mav.addObject("defaultLoc", request.getParameter("location")); if (request.getParameter("dateFrom") == null || request.getParameter("dateFrom").compareTo("") == 0) mav.addObject("from", df.format(new Date(today.getYear(), today.getMonth(), 1))); else mav.addObject("from", request.getParameter("dateFrom")); if (request.getParameter("dateTo") == null || request.getParameter("dateTo").compareTo("") == 0) mav.addObject("to", df.format(today)); else mav.addObject("to", request.getParameter("dateTo")); // VCTModuleService vms=Context.getService(VCTModuleService.class); // vms.getCouplesCounseledAndTested(request.getParameter("dateFrom"), request.getParameter("dateTo"), VCTConfigurationUtil.getDefaultLocationId()); } catch (Exception e) { request.getSession().setAttribute(WebConstants.OPENMRS_ERROR_ATTR, getMessageSourceAccessor().getMessage("@MODULE_ID@.error.loadingData")); log.error(">>>>>>VCT>>TRACNET>>INDICATORS>> " + e.getMessage()); e.printStackTrace(); } }