List of usage examples for java.util Date setDate
@Deprecated public void setDate(int date)
From source file:attask.engine.ATTaskInterface.java
public static String getCurrentFormattedDateSetDate(int day) { SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");//dd/MM/yyyy Date now = new Date(); now.setDate(day); String strDate = sdfDate.format(now); return strDate; }
From source file:ucd.denver.com.diskussioner.entityParser.parseToJson.java
public static List<Discussion> parseToDiscussion(String content) { try {//from w w w. jav a 2s . c o m JSONArray ja = new JSONArray(content); List<Discussion> disList = new ArrayList<>(); for (int i = 0; i < ja.length(); i++) { JSONObject jo = ja.getJSONObject(i); Discussion d = new Discussion(); d.setId(jo.getInt("id")); String da = jo.getString("started_date").toString(); System.out.println(da); Date statedDate = new Date(); String[] dateSplit = da.split("-"); statedDate.setYear(Integer.parseInt(dateSplit[0]) - 1900); statedDate.setMonth(Integer.parseInt(dateSplit[1])); statedDate.setDate(Integer.parseInt(dateSplit[2])); System.out.println(statedDate); System.out.println("stated Date" + statedDate); d.setStartedDate(statedDate); d.setTopic(jo.getString("topic")); User u = new User(); u.setEmail(jo.getString("started_user")); d.setStartedUser(u); disList.add(d); } System.out.println("dis List size:::" + disList.size()); return disList; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:attask.engine.ATTaskInterface.java
public static String calculateFormattedTimesheetStartDate() { SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");//dd/MM/yyyy Date now = new Date(); int timesheetStart; Calendar cal = Calendar.getInstance(); int currDay = cal.get(Calendar.DAY_OF_MONTH); if (currDay < 16) { timesheetStart = 1;/*from w ww .ja v a 2 s .c o m*/ } else { timesheetStart = 16; } now.setDate(timesheetStart); String strDate = sdfDate.format(now); return strDate; }
From source file:sr.ifes.edu.br.bd2.util.datafactory.LocacaoData.java
public Locacao build(DataFactory df) { Locacao locacao = new Locacao(); locacao.setDataLocacao(df.getDateBetween(df.getDate(1960, 1, 1), df.getDate(2015, 8, 1))); Date dataDevolucao = new Date(); int diasAmais = df.getNumberBetween(5, 15); dataDevolucao.setDate(locacao.getDataLocacao().getDate() + diasAmais); locacao.setDataDevolucao(dataDevolucao); locacao.setCliente(clienteData.build(df)); locacao.setFilme(filmeData.build(df)); if (diasAmais > 5) { locacao.setMulta(new Double(((diasAmais - 5) * 2))); }//from www . j a v a 2 s .c o m return locacao; }
From source file:org.openmrs.module.vcttrac.web.view.chart.EvolutionOfClientRegisteredPerDay.java
/** * @see org.openmrs.module.vcttrac.web.view.chart.AbstractChartView#createChart(java.util.Map, * javax.servlet.http.HttpServletRequest) *///w ww.java 2s. com @Override protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) { String categoryAxisLabel = VCTTracUtil.getMessage("vcttrac.graph.evolution.yAxis.days", null); String valueAxisLabel = VCTTracUtil.getMessage("vcttrac.graph.evolution.xAxis.numberofclient", null); int numberOfDays = 7, dayFormat = 1; if (request.getParameter("graphCategory") != null) { if (request.getParameter("graphCategory").trim().compareTo("2") == 0) { Date d = new Date(); d.setDate(1); d.setMonth((new Date()).getMonth()); d.setYear((new Date()).getYear()); numberOfDays = (int) (((new Date()).getTime() - d.getTime()) / VCTTracConstant.ONE_DAY_IN_MILLISECONDS); categoryAxisLabel = VCTTracUtil.getMessage("vcttrac.month." + ((new Date()).getMonth() + 1), null); dayFormat = 2; } } String title = ""; title = VCTTracUtil.getMessage("vcttrac.graph.evolution.client.received", null); JFreeChart chart = ChartFactory.createLineChart(title, categoryAxisLabel, valueAxisLabel, createDataset(numberOfDays, dayFormat), // data PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setUpperMargin(0.15); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); return chart; }
From source file:org.apache.hadoop.hive.ql.udf.UDFNextDay.java
public String evaluate(String date, Integer day) { if (date == null || day == null) { return null; }//w w w .ja v a2 s . c o m if (day < 1 || day > 7) { return null; } Pattern pattern = Pattern.compile("([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])[\\s\\S]*(\\..*)?$"); Matcher matcher = pattern.matcher(date); if (!matcher.matches()) { return null; } int year = Integer.valueOf(matcher.group(1)); int month = Integer.valueOf(matcher.group(2)); int dd = Integer.valueOf(matcher.group(3)); Date ret = new Date(); ret.setYear(year - 1900); ret.setMonth(month - 1); ret.setDate(dd); ret.setHours(0); ret.setMinutes(0); ret.setSeconds(0); Calendar curr = Calendar.getInstance(); curr.setTime(ret); int curr_week = curr.get(Calendar.DAY_OF_WEEK); int offset = 7 + (day - curr_week); curr.add(Calendar.DAY_OF_WEEK, offset); Date newDate = curr.getTime(); System.out.println("newDate:" + newDate.toString()); year = curr.get(Calendar.YEAR); month = curr.get(Calendar.MONTH) + 1; dd = curr.get(Calendar.DAY_OF_MONTH); System.out.println("curr.get(Calendar.MONTH):" + curr.get(Calendar.MONTH)); return String.format("%04d-%02d-%02d", year, month, dd); }
From source file:com.wonders.stpt.metroIndicator.service.impl.MetroProductionServiceImpl.java
@SuppressWarnings("deprecation") public List<ProductionVo> findSevenDaysProduction(String endDate, String line) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List<ProductionVo> voList = new ArrayList<ProductionVo>(); if (endDate == null || "".equals(endDate)) { endDate = sdf.format(new Date()); }//from w ww . j a v a 2 s . c om try { //? List<MetroProduction> dataList = metroProductionDao.findProductionWithData(endDate, line); if (dataList != null && dataList.size() != 0) { endDate = dataList.get(0).getIndicatorDate(); } Date start = sdf.parse(endDate); // start.setDate(start.getDate() - 5); List<MetroProduction> productList = metroProductionDao.findSevenDaysProduction(sdf.format(start), endDate, line); if (productList != null && productList.size() != 0) { for (int i = 0; i < productList.size(); i++) { ProductionVo vo = new ProductionVo(productList.get(i)); voList.add(vo); } } return voList; } catch (ParseException e) { return null; } }
From source file:com.springsource.greenhouse.events.sessions.EventSessionsScheduleActivity.java
private void refreshScheduleDays() { if (event == null) { return;/*from w w w . j a v a 2 s . c om*/ } conferenceDates = new ArrayList<Date>(); List<String> conferenceDays = new ArrayList<String>(); Date day = (Date) event.getStartTime().clone(); while (day.before(event.getEndTime())) { conferenceDates.add((Date) day.clone()); conferenceDays.add(new SimpleDateFormat("EEEE, MMM d").format(day)); day.setDate(day.getDate() + 1); } setListAdapter(new ArrayAdapter<String>(this, R.layout.menu_list_item, conferenceDays)); }
From source file:accountgen.controller.Controller.java
private void getListTags(Document doc, Person p) { Elements li = doc.select(".extra").select("li:not(.lab)"); p.setUsername(li.get(2).text());//from www . jav a 2 s . c o m p.setPassword(li.get(3).text()); p.setMmn(li.get(4).text()); p.setMastercard(li.get(6).text()); p.setSsn(""); Date d = new Date(); d.setDate(1); d.setYear(Integer.parseInt(li.get(7).text().split("/")[1]) - 1900); d.setMonth(Integer.parseInt(li.get(7).text().split("/")[0]) - 1); p.setExpires(d); p.setCvv2(li.get(8).text()); p.setFavoritecolor(li.get(9).text()); p.setOccupation(li.get(10).text()); p.setCompany(li.get(11).text()); p.setWebsite(li.get(12).text()); Vehicle v = new Vehicle(); v.setModel(li.get(13).text().split(" ")[li.get(13).text().split(" ").length - 1].trim()); v.setYear(Integer.parseInt(li.get(13).text().split(" ")[0].trim())); v.setBrand( li.get(13).text().replace(li.get(13).text().split(" ")[li.get(13).text().split(" ").length - 1], "") .replace(li.get(13).text().split(" ")[0], "").trim()); p.setVehicle(v); p.setUpsnr(li.get(14).text()); p.setBloodtype(li.get(15).text()); p.setWeight(li.get(16).text().split("\\(")[1].split(" ")[0]); p.setHeight(li.get(17).text().split("\\(")[1].split(" ")[0]); p.setGuid(li.get(18).text()); }
From source file:org.epics.archiverappliance.etl.ConsolidateETLJobsForOnePVTest.java
@SuppressWarnings("deprecation") private void Consolidate() throws AlreadyRegisteredException, IOException, InterruptedException { PVTypeInfo typeInfo = new PVTypeInfo(pvName, ArchDBRTypes.DBR_SCALAR_DOUBLE, true, 1); String[] dataStores = new String[] { storageplugin1.getURLRepresentation(), storageplugin2.getURLRepresentation(), storageplugin3.getURLRepresentation() }; typeInfo.setDataStores(dataStores);/*from w w w .ja va 2 s . c om*/ configService.updateTypeInfoForPV(pvName, typeInfo); configService.registerPVToAppliance(pvName, configService.getMyApplianceInfo()); configService.getETLLookup().manualControlForUnitTests(); //generate datas of 10 days PB file 2012_01_01.pb to 2012_01_10.pb int dayCount = 10; for (int day = 0; day < dayCount; day++) { logger.debug("Generating data for day " + 1); int startofdayinseconds = day * 24 * 60 * 60; int runsperday = 12; int eventsperrun = 24 * 60 * 60 / runsperday; for (int currentrun = 0; currentrun < runsperday; currentrun++) { try (BasicContext context = new BasicContext()) { logger.debug("Generating data for run " + currentrun); YearSecondTimestamp yts = new YearSecondTimestamp(currentYear, (day + 1) * 24 * 60 * 60, 0); Timestamp etlTime = TimeUtils.convertFromYearSecondTimestamp(yts); logger.debug("Running ETL as if it were " + TimeUtils.convertToHumanReadableString(etlTime)); ETLExecutor.runETLs(configService, etlTime); ArrayListEventStream testData = new ArrayListEventStream(eventsperrun, new RemotableEventStreamDesc(type, pvName, currentYear)); for (int secondsinrun = 0; secondsinrun < eventsperrun; secondsinrun++) { testData.add( new SimulationEvent(startofdayinseconds + currentrun * eventsperrun + secondsinrun, currentYear, type, new ScalarValue<Double>((double) secondsinrun))); } storageplugin1.appendData(context, pvName, testData); } // Sleep for a couple of seconds so that the modification times are different. Thread.sleep(2 * 1000); } } // end for File shortTermFIle = new File(shortTermFolderName); File mediumTermFIle = new File(mediumTermFolderName); //File longTermFIle=new File(longTermFolderName); String[] filesShortTerm = shortTermFIle.list(); String[] filesMediumTerm = mediumTermFIle.list(); assertTrue("there should be PB files int short term storage but there is no ", filesShortTerm.length != 0); assertTrue("there should be PB files int medium term storage but there is no ", filesMediumTerm.length != 0); //ArchUnitTestConsolidateETLJobsForOnePVTest:_pb.zip File zipFileOflongTermFile = new File(longTermFolderName + "/" + pvName + ":_pb.zip"); assertTrue(longTermFolderName + "/" + pvName + ":_pb.zip shoule exist but it doesn't", zipFileOflongTermFile.exists()); ZipFile lastZipFile1 = new ZipFile(zipFileOflongTermFile); Enumeration<ZipArchiveEntry> enumeration1 = lastZipFile1.getEntries(); int ss = 0; while (enumeration1.hasMoreElements()) { enumeration1.nextElement(); ss++; } assertTrue( "the zip file of " + longTermFolderName + "/" + pvName + ":_pb.zip should contain pb files less than " + dayCount + ",but the number is " + ss, ss < dayCount); // consolidate String storageName = "LTS"; Timestamp oneYearLaterTimeStamp = TimeUtils .convertFromEpochSeconds(TimeUtils.getCurrentEpochSeconds() + 365 * 24 * 60 * 60, 0); // The ConfigServiceForTests automatically adds a ETL Job for each PV. For consolidate, we need to have "paused" the PV; we fake this by deleting the jobs. configService.getETLLookup().deleteETLJobs(pvName); ETLExecutor.runPvETLsBeforeOneStorage(configService, oneYearLaterTimeStamp, pvName, storageName); // make sure there are no pb files in short term storage , medium term storage and all files in long term storage Thread.sleep(4000); String[] filesShortTerm2 = shortTermFIle.list(); String[] filesMediumTerm2 = mediumTermFIle.list(); assertTrue("there should be no files int short term storage but there are still " + filesShortTerm2.length + "PB files", filesShortTerm2.length == 0); assertTrue("there should be no files int medium term storage but there are still " + filesMediumTerm2.length + "PB files", filesMediumTerm2.length == 0); //ArchUnitTestConsolidateETLJobsForOnePVTest:_pb.zip File zipFileOflongTermFile2 = new File(longTermFolderName + "/" + pvName + ":_pb.zip"); assertTrue(longTermFolderName + "/" + pvName + ":_pb.zip shoule exist but it doesn't", zipFileOflongTermFile2.exists()); ZipFile lastZipFile = new ZipFile(zipFileOflongTermFile2); Enumeration<ZipArchiveEntry> enumeration = lastZipFile.getEntries(); ZipEntry zipEntry = null; HashMap<String, String> fileNameMap = new HashMap<String, String>(); while (enumeration.hasMoreElements()) { zipEntry = (ZipEntry) enumeration.nextElement(); String fileNameTemp = zipEntry.getName(); logger.info("fileName1=" + fileNameTemp); int indexPB = fileNameTemp.indexOf(".pb"); int indexDate = indexPB - 5; String dateFileName = fileNameTemp.substring(indexDate, indexPB); fileNameMap.put(dateFileName, dateFileName); //System.out.println("fileName="+dateFileName); logger.info("fileName=" + dateFileName); } assertTrue("The number of files should be " + dayCount + ", acutuallly, it is " + fileNameMap.size(), fileNameMap.size() == dayCount); Date beinningDate = new Date(); beinningDate.setYear(currentYear - 1); beinningDate.setMonth(11); beinningDate.setDate(31); logger.info("currentYear=" + currentYear); logger.info("beinningDate=" + beinningDate); Calendar calendarBeingining = Calendar.getInstance(); calendarBeingining.setTime(beinningDate); SimpleDateFormat df = new SimpleDateFormat("MM_dd"); for (int m = 0; m < dayCount; m++) { calendarBeingining.add(Calendar.DAY_OF_MONTH, 1); String fileNameTemp1 = df.format(calendarBeingining.getTime()); logger.info("fileNameTemp1=" + fileNameTemp1); assertTrue("the file whose name is like " + pvName + ":" + currentYear + "_" + fileNameTemp1 + ".pb should exist,but it doesn't", fileNameMap.get(fileNameTemp1) != null); } }