List of usage examples for java.util Calendar DATE
int DATE
To view the source code for java.util Calendar DATE.
Click Source Link
get
and set
indicating the day of the month. From source file:com.alcatel_lucent.nz.wnmsextract.reader.BorgSelectionReader.java
@Override public void readAll() { Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance();//today start.add(Calendar.DATE, -1);//today-1 readAll(start, end);//w w w .j a va 2s . co m }
From source file:py.una.pol.karaku.test.test.FormatProviderTest.java
/** * *///from www. j a v a 2 s . c o m @Before public void setUp() { calendar = GregorianCalendar.getInstance(); calendar.set(Calendar.YEAR, 2013); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.DATE, 1); calendar.set(Calendar.HOUR_OF_DAY, 6); calendar.set(Calendar.MINUTE, 30); calendar.set(Calendar.SECOND, 10); date = calendar.getTime(); veryLarge = this.getByString("1000000000000"); large = this.getByString("100000"); small = this.getByString("100"); verySmall = this.getByString("1"); decimal = this.getByString("0.111"); decimalUP = this.getByString("0.119"); smallDecimal = this.getByString("0.0111"); smallDecimalUP = this.getByString("0.0159"); }
From source file:net.sourceforge.eclipsetrader.opentick.HistoryFeed.java
public void updateHistory(Security security, int interval) { try {// w ww. j av a 2s . c o m client.login(15 * 1000); } catch (Exception e) { log.error(e, e); } if (interval == IHistoryFeed.INTERVAL_DAILY) { log.info("Updating historical data for " + security); try { requestHistoryStream(security, 60 * 1000); } catch (Exception e) { log.error(e, e); } } if (interval == IHistoryFeed.INTERVAL_MINUTE) { String symbol = security.getHistoryFeed().getSymbol(); if (symbol == null || symbol.length() == 0) symbol = security.getCode(); String exchange = security.getHistoryFeed().getExchange(); if (exchange == null || exchange.length() == 0) exchange = "Q"; History history = security.getIntradayHistory(); history.clear(); BackfillClientAdapter adapter = new BackfillClientAdapter(security); client.addListener(adapter); Calendar from = Calendar.getInstance(); from.set(Calendar.HOUR, 0); from.set(Calendar.MINUTE, 0); from.set(Calendar.SECOND, 0); from.set(Calendar.MILLISECOND, 0); from.add(Calendar.DATE, -5); int startTime = (int) (from.getTimeInMillis() / 1000); Calendar to = Calendar.getInstance(); to.set(Calendar.MILLISECOND, 0); int endTime = (int) (to.getTimeInMillis() / 1000); log.info("Updating intraday data for " + security); adapter.started = System.currentTimeMillis(); try { adapter.historyStream = client.requestHistData(new OTDataEntity(exchange, symbol), startTime, endTime, OTConstants.OT_HIST_OHLC_MINUTELY, 1); while ((System.currentTimeMillis() - adapter.started) < 60 * 1000 && !adapter.isCompleted()) Thread.sleep(100); } catch (Exception e) { log.error(e, e); } client.removeListener(adapter); Collections.sort(security.getDividends(), new Comparator() { public int compare(Object o1, Object o2) { return ((Dividend) o1).getDate().compareTo(((Dividend) o2).getDate()); } }); Collections.sort(security.getSplits(), new Comparator() { public int compare(Object o1, Object o2) { return ((Split) o1).getDate().compareTo(((Split) o2).getDate()); } }); CorePlugin.getRepository().save(history); CorePlugin.getRepository().save(security); } }
From source file:org.duracloud.mill.manifest.cleaner.ManifestCleanerDriver.java
/** * @param time//from w w w .ja va 2s . c om * @return * @throws ParseException */ private Date parseExpirationDate(String time) throws ParseException { Calendar c = Calendar.getInstance(); String pattern = "([0-9]+)([smhd])"; if (!time.matches(pattern)) { throw new ParseException(time + " is not a valid time value."); } int amount = Integer.parseInt(time.replaceAll(pattern, "$1")); String units = time.replaceAll(pattern, "$2"); int field = Calendar.SECOND; if (units.equals("m")) { field = Calendar.MINUTE; } else if (units.equals("h")) { field = Calendar.HOUR; } else if (units.equals("d")) { field = Calendar.DATE; } else { // should never happen. throw new RuntimeException("unit " + units + " not recognized."); } c.add(field, -1 * amount); return c.getTime(); }
From source file:it.govpay.web.rs.dars.base.StatisticaDarsHandler.java
protected Date calcolaAvanzamento(Date data, int avanzamento, TipoIntervallo tipoIntervallo) throws ConsoleException { if (avanzamento != 0) { Calendar calendar = Calendar.getInstance(); calendar.setTime(data);/* w w w .j a v a 2 s . c om*/ switch (tipoIntervallo) { case MENSILE: calendar.add(Calendar.MONTH, avanzamento); break; case GIORNALIERO: calendar.add(Calendar.DATE, avanzamento); break; case ORARIO: calendar.add(Calendar.HOUR, avanzamento); break; } return calendar.getTime(); } return data; }
From source file:edu.indiana.htrc.visual.HTRCSeriesChartDrawer.java
@Override public File draw() { Set<String> key_set = input_map.keySet(); Iterator<String> iter = key_set.iterator(); TimeSeries accessSeries = new TimeSeries(dataset_label, Day.class); while (iter.hasNext()) { String dateStr = iter.next(); // yyyy-MM-dd int value = input_map.get(dateStr); Date date = null;//from ww w . j a va 2 s. c o m try { date = format.parse(dateStr); System.out.println(date); cal.setTime(date); accessSeries.add( new Day(cal.get(Calendar.DATE), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.YEAR)), value); } catch (ParseException e) { e.printStackTrace(); } } TimeSeriesCollection series_dataset = new TimeSeriesCollection(); series_dataset.addSeries(accessSeries); JFreeChart series_chart = ChartFactory.createTimeSeriesChart(chart_name, x_axis_label, y_axis_label, series_dataset, true, true, false); File img = new File("../webapps/HTRC-UI-AuditAnalyzer/images/" + System.currentTimeMillis() + ".jpg"); try { ChartUtilities.saveChartAsJPEG(img, series_chart, 1400, 600); } catch (IOException e) { e.printStackTrace(); } return img; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.NSFCoverPageBaseGenerator.java
/** * /*ww w .j ava 2 s . co m*/ * This method Converts the String that is passed to it into a calendar * object. The argument will be set as the Year in the Calendar Object. * * @param year - * The String value to be converted to Calendar Object * @return calendar value corresponding to the year(String) passed. */ public Calendar getYearAsCalendar(String year) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.DATE, 0); calendar.set(Calendar.MONTH, 0); try { calendar.set(Calendar.YEAR, Integer.parseInt(year)); } catch (NumberFormatException ex) { calendar.set(Calendar.YEAR, 0); } return calendar; }
From source file:cvr.vist.stat.comps.DateFilterArea.java
public Date getDateEnd() { return DateUtils.truncate(dateTo.getValue(), Calendar.DATE); }
From source file:ddf.metrics.reporting.internal.rrd4j.RrdDumper.java
private static String getCalendarTime(long timestamp) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timestamp * 1000); String calTime = months[calendar.get(Calendar.MONTH)] + " " + calendar.get(Calendar.DATE) + " " + calendar.get(Calendar.YEAR) + " "; calTime += addLeadingZero(calendar.get(Calendar.HOUR_OF_DAY)) + ":"; calTime += addLeadingZero(calendar.get(Calendar.MINUTE)) + ":"; calTime += addLeadingZero(calendar.get(Calendar.SECOND)); return calTime; }
From source file:org.openmrs.module.rwandaprimarycare.ExtendPatientNameSearchController.java
@RequestMapping("/module/rwandaprimarycare/extendNameSearch") public String setupForm(@RequestParam("givenName") String givenName, @RequestParam("familyName") String familyName, @RequestParam("gender") String gender, @RequestParam("age") Integer age, @RequestParam(required = false, value = "birthdateDay") Integer birthdateDay, @RequestParam(required = false, value = "birthdateMonth") Integer birthdateMonth, @RequestParam(required = false, value = "birthdateYear") Integer birthdateYear, @RequestParam("country") String country, @RequestParam("province") String province, @RequestParam("district") String district, @RequestParam("sector") String sector, @RequestParam("cell") String cell, @RequestParam("address1") String address1, HttpSession session, ModelMap model) throws PrimaryCareException { // LK: Need to ensure that all primary care methods only throw a // PrimaryCareException // So that errors will be directed to a touch screen error page GetPatientUtil getPatientUtil = new GetPatientUtil(); try {/*from w ww. j ava2s. co m*/ if (givenName != null) { log.info("FANAME >> " + givenName); log.info("RWNAME >> " + familyName); model.addAttribute("givenName", givenName); TreeMap<String, String> params = new TreeMap<String, String>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); Calendar c = Calendar.getInstance(); c.add(Calendar.YEAR, -age); c.add(Calendar.DATE, -183); Date d = c.getTime(); int year = d.getYear(); String df = sdf.format(d); log.info(df + "<< >>" + year); params.put("dob", df); if (givenName != null && givenName != "") { params.put("given_name", givenName); } if (familyName != null && familyName != "") { params.put("family_name", familyName); } if (gender != null && gender != "") { params.put("gender", gender); } if (province != null && province != "") { params.put("addr_province", province); } if (district != null && district != "") { params.put("addr_district", district); } if (sector != null && sector != "") { params.put("addr_sector", sector); } if (cell != null && cell != "") { params.put("addr_cell", cell); } if (address1 != null && address1 != "") { params.put("addr_village", address1); } model.addAttribute("givenName", givenName); model.addAttribute("familyName", familyName); model.addAttribute("gender", gender); model.addAttribute("age", age); model.addAttribute("searchUMUDUGUDU", address1); model.addAttribute("searchCELL", cell); model.addAttribute("searchDISTRICT", district); model.addAttribute("searchCOUNTRY", country); model.addAttribute("searchPROVINCE", province); model.addAttribute("searchSECTOR", sector); //model.addAttribute("CR", "Client Reg"); //List<AttributeList> result = new ArrayList<AttributeList>(); // List<Patient> extendedResults = getPatientUtil // .getPatientFromClientReg(params); List<AttributeList> results = getPatientUtil.getPatientWithAttributeListFromClientReg(params); if (results.size() > 0) { for (AttributeList al : results) { String nid = ""; if (al.getPatient().getPatientIdentifier("NID") != null) { nid = al.getPatient().getPatientIdentifier("NID").getIdentifier(); al.setNid(nid); log.info("Moms name == " + al.getMothersName()); } else { nid = "Unavailable"; al.setNid(nid); } } } // if(extendedResults.size()>0){ // for(Patient p:extendedResults){ // String mothersName=""; // String fathersName=""; // String nid = ""; // if(p.getPatientIdentifier("NID")!=null){ // nid = p.getPatientIdentifier("NID").getIdentifier(); // } // else{ // nid = "Unavailable"; // } // PersonAttributeType mName = Context.getPersonService().getPersonAttributeTypeByName( // PrimaryCareConstants.MOTHER_NAME_ATTRIBUTE_TYPE) ; // PersonAttributeType fName = Context.getPersonService().getPersonAttributeTypeByName( // PrimaryCareConstants.FATHER_NAME_ATTRIBUTE_TYPE) ; // // if (p.getAttribute(mName) != null) { // mothersName = p.getAttribute(mName).getValue(); // // } // // if (p.getAttribute(fName) != null) { // fathersName = p.getAttribute(fName).getValue(); // // } // // AttributeList al = new AttributeList(p, mothersName, fathersName, nid); // results.add(al); // // } // } // model.addAttribute("results", results); model.addAttribute("identifierTypes", PrimaryCareBusinessLogic.getPatientIdentifierTypesToUse()); } } catch (Exception e) { e.printStackTrace(); throw new PrimaryCareException(e); } return "/module/rwandaprimarycare/extendedResults"; }