List of usage examples for java.util Date getYear
@Deprecated public int getYear()
From source file:com.mongodb.hadoop.examples.TreasuryYieldMapper.java
public void map(java.util.Date key, BSONObject value, Context context) throws IOException, InterruptedException { int year = key.getYear() + 1900; double bid10Year = ((Number) value.get("bc10Year")).doubleValue(); context.write(new IntWritable(year), new DoubleWritable(bid10Year)); }
From source file:org.eclipse.flux.cloudfoundry.deployment.service.CfDeploymentService.java
private CloudFoundryClientDelegate getCfClient(JSONObject req) throws Exception { DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(req.getString(CF_TOKEN)); //We must set expiration or CF client will try to refresh it and throw an NPE because it has no // refresh token. See https://github.com/cloudfoundry/cf-java-client/issues/214 Date nextYear = new Date(); nextYear.setYear(nextYear.getYear() + 1); token.setExpiration(nextYear);/*w ww . jav a 2 s. c om*/ return new CloudFoundryClientDelegate(req.getString(USERNAME), token, new URI(req.getString(CF_CONTROLLER_URL)).toURL(), getStringMaybe(req, CF_SPACE), flux, appLogs); }
From source file:manipulaxmls.Copiar.java
public void copiarXml(String origemNfe) { File diretorio;/*from www . j a va 2 s . c o m*/ diretorio = new File(origemNfe); if (diretorio.exists()) { Date modifica = new Date(diretorio.lastModified()); System.out.println("ultima modificacao: " + modifica); File[] lista = diretorio.listFiles(); File destino = new File(System.getProperty("user.home") + "\\desktop\\contador"); if (destino.exists()) { } else { destino.mkdir(); } for (File lista1 : lista) { Date dataArq = new Date(lista1.lastModified()); int anoArq = dataArq.getYear() + 1900; int mesArq = dataArq.getMonth() + 1; File pastaAno = new File(System.getProperty("user.home") + "\\desktop\\contador" + "\\" + anoArq); File pastaMes = new File( System.getProperty("user.home") + "\\desktop\\contador" + "\\" + anoArq + "\\" + mesArq); if (pastaAno.exists()) { } else { pastaAno.mkdir(); } if (pastaMes.exists()) { } else { pastaMes.mkdir(); } String nomeArq = lista1.getName(); if (nomeArq.length() == 51) { try { destino = pastaMes; FileUtils.copyFileToDirectory(lista1, destino); } catch (Exception ex) { System.out.println("ERRO! " + ex); } } } } else { System.out.println("CAMINHO INEXISTENTE !!!"); System.out.println("diretorio :" + diretorio); } }
From source file:org.openmrs.module.pmtct.PregnancyDateManager.java
@SuppressWarnings("deprecation") public String getDPA(String dateOfPeriod) throws Exception { Date lastDateOfPeriod = Context.getDateFormat().parse(dateOfPeriod); GregorianCalendar last_DateOfPeriod = new GregorianCalendar(lastDateOfPeriod.getYear() + 1900, lastDateOfPeriod.getMonth(), lastDateOfPeriod.getDate()); last_DateOfPeriod.setLenient(false); last_DateOfPeriod.add(Calendar.DAY_OF_YEAR, PMTCTConstants.DELAY_IN_DAYS_OF_PREGNANCY); return Context.getDateFormat().format(last_DateOfPeriod.getTime()); }
From source file:org.openmrs.module.pmtct.PregnancyDateManager.java
@SuppressWarnings("deprecation") public String getNumberOfWeeks(String dateOfPeriod) throws Exception { Date lastDateOfPeriod = Context.getDateFormat().parse(dateOfPeriod); GregorianCalendar last_DateOfPeriod = new GregorianCalendar(lastDateOfPeriod.getYear(), lastDateOfPeriod.getMonth(), lastDateOfPeriod.getDate()); last_DateOfPeriod.setLenient(false); Date da = new Date(); // slog.info("xxxxxxxxxxxxxxx"+(new GregorianCalendar(da.getYear()+1900,da.getMonth(),da.getDate())).getTime()); //1 week=604800000 milliseconds = (1000ms*60s*60min*24h*7days) return "**********************" + (((new GregorianCalendar(da.getYear(), da.getMonth(), da.getDate())).getTimeInMillis()) - (last_DateOfPeriod.getTimeInMillis())) / 604800000; }
From source file:org.alfresco.repo.web.scripts.content.StreamJMXDump.java
/** * @see org.springframework.extensions.webscripts.WebScript#execute(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse) *//*w ww . j av a2s. co m*/ public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException { PrintWriter tempFileOut = null; ZipOutputStream zout = null; try { // content type and caching res.setContentType("application/zip"); Cache cache = new Cache(); cache.setNeverCache(true); cache.setMustRevalidate(true); cache.setMaxAge(0L); res.setCache(cache); Date date = new Date(); String attachFileName = "jmxdump_" + (date.getYear() + 1900) + '_' + (date.getMonth() + 1) + '_' + (date.getDate()); String headerValue = "attachment; filename=\"" + attachFileName + ".zip\""; // set header based on filename - will force a Save As from the browse if it doesn't recognize it // this is better than the default response of the browser trying to display the contents res.setHeader("Content-Disposition", headerValue); // write JMX data to temp file File tempFile = TempFileProvider.createTempFile("jmxdump", ".txt"); tempFileOut = new PrintWriter(tempFile); JmxDumpUtil.dumpConnection(mbeanServer, tempFileOut); tempFileOut.flush(); tempFileOut.close(); tempFileOut = null; // zip output zout = new ZipOutputStream(res.getOutputStream()); ZipEntry zipEntry = new ZipEntry(attachFileName + ".txt"); zout.putNextEntry(zipEntry); FileCopyUtils.copy(new FileInputStream(tempFile), zout); zout = null; } catch (IOException ioe) { throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not output JMX dump: " + ioe.getMessage(), ioe); } finally { if (tempFileOut != null) tempFileOut.close(); try { if (zout != null) zout.close(); } catch (IOException e1) { } } }
From source file:org.dspace.statistics.content.StatisticsDataWorkflow.java
private int getMonthsDifference(Date date1, Date date2) { int m1 = date1.getYear() * 12 + date1.getMonth(); int m2 = date2.getYear() * 12 + date2.getMonth(); return m2 - m1 + 1; }
From source file:com.gizwits.aircondition.activity.control.MainControlActivity.java
/** * ??2014624 17:23./*from w w w . j ava 2s. co m*/ * * @param date * the date * @return the date cn */ public static String getDateCN(Date date) { int y = date.getYear(); int m = date.getMonth() + 1; int d = date.getDate(); int h = date.getHours(); int mt = date.getMinutes(); return (y + 1900) + "" + m + "" + d + " " + h + ":" + mt; }
From source file:com.wonders.stpt.metroIndicator.service.impl.MetroProductionServiceImpl.java
@SuppressWarnings("deprecation") public MetroProduction findSamePeriodLastYear(String now, String line) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List<MetroProduction> dataList = metroProductionDao.findProductionWithData(now, line); if (dataList != null && dataList.size() != 0) { now = dataList.get(0).getIndicatorDate(); }//from w w w . ja va2s .co m try { Date lastyear = sdf.parse(now); // lastyear.setYear(lastyear.getYear() - 1); List<MetroProduction> list = metroProductionDao.findSamePeriodLastYear(sdf.format(lastyear), line); if (list != null && list.size() > 0) return list.get(0); return null; } catch (ParseException e) { return null; } }
From source file:com.dare2date.externeservice.lastfm.LastfmAPI.java
/** * Adds date data to an event.//w w w .j a v a 2 s . c o m * @param eventdata * @param event */ private void addDateToEventFromJSONData(JSONObject eventdata, LastfmEvent event) { try { Calendar date = Calendar.getInstance(); Date _date = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.ENGLISH) .parse(eventdata.get("startDate").toString()); date.set(_date.getYear(), _date.getMonth(), _date.getDay(), _date.getHours(), _date.getMinutes(), _date.getSeconds()); event.setStartDate(date); } catch (ParseException e) { e.printStackTrace(); } }