List of usage examples for org.joda.time DateTime plusDays
public DateTime plusDays(int days)
From source file:backend.util.FileGroup.java
public static void main(String[] args) throws IOException { boolean Done = false; do {//from ww w . j a va2 s.c om DateTimeFormatter templFMT = DateTimeFormat.forPattern("yyyy-MM-dd"); DateTimeFormatter subDirFMT = DateTimeFormat.forPattern("yyMMdd"); JFileChooser fChooser = new JFileChooser("D:\\CGKStudio\\log"); fChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // fChooser.setFileFilter(new FileNameExtensionFilter("LOG File","")); if (fChooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) return; File dir = fChooser.getSelectedFile(); List<File> files = new LinkedList(Arrays.asList(dir.listFiles())); DateTime d = new DateTime(2014, 11, 20, 0, 0); DateTime now = DateTime.now(); while (d.compareTo(now) <= 0) { String templ = templFMT.print(d); List<File> moved = new LinkedList(); files.stream().filter((file) -> (file.getName().contains(templ))).forEach((file) -> { moved.add(file); }); files.removeAll(moved); if (moved.size() > 0) { String subDir = dir.getAbsolutePath() + "\\" + subDirFMT.print(d); File subDirFile = new File(subDir); if (!subDirFile.exists()) Files.createDirectory(subDirFile.toPath()); moved.stream().forEach((file) -> { try { File target = new File(subDir + "\\" + file.getName()); if (!target.exists()) { Files.copy(new File(dir.getAbsolutePath() + "\\" + file.getName()).toPath(), target.toPath()); } } catch (IOException ex) { Logger.getLogger(FileGroup.class.getName()).log(Level.SEVERE, null, ex); } }); } d = d.plusDays(1); } int sel; sel = JOptionPane.showConfirmDialog(fChooser, "Do it again?", "Again", JOptionPane.YES_NO_OPTION); if (sel != JOptionPane.YES_OPTION) Done = true; } while (!Done); }
From source file:br.com.ma1s.eva.service.PaymentService.java
public PaymentService() { final DateTime dt = new DateTime().dayOfMonth().setCopy(1); this.monthBegin = dt.toDate(); this.monthEnd = dt.plusDays(30).toDate(); }
From source file:br.com.recursive.biblioteca.servicos.AcervoService.java
public void renovaEmprestimo(Emprestimo emprestimo) throws Exception { DateTime dataProgramadaDeDevolucao = new DateTime(emprestimo.getUltimaRenovacao().getDataDevolucao()); DateTime hoje = new DateTime(new Date()); int qtdeDiasMulta = Days.daysBetween(hoje, dataProgramadaDeDevolucao).getDays(); if (qtdeDiasMulta < 0) { throw new Exception( "<b>Emprstimos com multas no podem ser renovados!</b><br/>Esse emprstimo possui multa no valor de <b>R$ " + -1 * qtdeDiasMulta * 0.50 + "</b> referente a <b>" + (-1) * qtdeDiasMulta + " dias</b> de atraso"); } else if (emprestimo.getVezesEmprestimo().size() == 3) { throw new Exception( "<b>Quantidade mxima de Renovaes atingida!</b><br/>Cada emprstimo pode ser renovado somente por 2 vezes consecutivas."); } else if (!emprestimo.getTipoEmprestimo().equals(TipoEmprestimo.NORMAL)) { throw new Exception( "<b>Somente emprstimos normais podem ser renovados online</b>.<br>Dirija-se biblioteca para conversar com um dos atendentes."); } else {/*from ww w.j a v a2 s . co m*/ DateTime novaDataDeDevolucao = hoje.plusDays(10); Calendar calendar = Calendar.getInstance(); calendar.setTime(novaDataDeDevolucao.toDate()); int diaDaSemana = calendar.get(Calendar.DAY_OF_WEEK); if (diaDaSemana == 1) { novaDataDeDevolucao = novaDataDeDevolucao.plusDays(1); } else if (diaDaSemana == 7) { novaDataDeDevolucao = novaDataDeDevolucao.plusDays(2); } VezesEmprestimo ve = new VezesEmprestimo(); ve.setDataEmprestimo(new Date()); ve.setDataDevolucao(novaDataDeDevolucao.toDate()); ve.setFuncionario(emprestimo.getUltimaRenovacao().getFuncionario()); emprestimo.getVezesEmprestimo().add(ve); hibernateDAO.update(emprestimo); } }
From source file:brickhouse.udf.date.AddDaysUDF.java
License:Apache License
public String evaluate(String dateStr, int numDays) { DateTime dt = YYYYMMDD.parseDateTime(dateStr); DateTime addedDt = dt.plusDays(numDays); String addedDtStr = YYYYMMDD.print(addedDt); return addedDtStr; }
From source file:ch.emad.business.schuetu.BusinessImpl.java
License:Apache License
public void initZeilen(final boolean sonntag) { DateTime start; List<SpielZeile> zeilen; BusinessImpl.LOG.info("date: starttag -->" + this.getSpielEinstellungen().getStarttag()); final DateTime start2 = new DateTime(this.getSpielEinstellungen().getStart(), DateTimeZone.forID("Europe/Zurich")); BusinessImpl.LOG.info("date: starttag Europe/Zurich -->" + start2); if (!sonntag) { start = new DateTime(start2); zeilen = createZeilen(start, false); } else {/*from w w w .j a va 2 s. co m*/ start = new DateTime(start2); start = start.plusDays(1); zeilen = createZeilen(start, true); } BusinessImpl.LOG.info("-->" + zeilen); this.spielzeilenRepo.save(zeilen); }
From source file:ch.icclab.cyclops.client.UdrServiceClient.java
License:Open Source License
/** * Connects to the UDR Service and requests for the CDRs for a user between a time period * * @param from String//w w w . java 2 s . c om * @param to String * @param userId String * @param resourceId String * @return String */ public String getUserUsageData(String userId, String resourceId, Integer from, Integer to) { logger.trace( "BEGIN UserUsage getUserUsageData(String userId, String resourceId, Integer from, Integer to) throws IOException"); logger.trace("DATA UserUsage getUserUsageData...: user=" + userId); Gson gson = new Gson(); LinearRegressionPredict predict = new LinearRegressionPredict(); //parse dates DateTime now = new DateTime(DateTimeZone.UTC); Long time_to = now.plusDays(to).getMillis(); String time_string_from = now.minusDays(from).toString("yyyy-MM-dd'T'HH:mm:ss'Z'"); ArrayList<Double> list_of_points = Time.makeListOfTIme(now, time_to, to); ClientResource resource = new ClientResource(url + "/usage/users/" + userId); resource.getReference().addQueryParameter("from", time_string_from); logger.trace("DATA UserUsage getUserUsageData...: url=" + resource.toString()); resource.get(MediaType.APPLICATION_JSON); Representation output = resource.getResponseEntity(); PredictionResponse result = new PredictionResponse(); try { JSONObject resultArray = new JSONObject(output.getText()); logger.trace("DATA UserUsage getUserUsageData...: output=" + resultArray.toString()); logger.trace("DATA UserUsage getUsageUsageData...: resultArray=" + resultArray); String result_array = resultArray.toString(); if (result_array.contains("OpenStack")) { result_array = result_array.replace("OpenStack", "External"); } UdrServiceResponse usageDataRecords = gson.fromJson(result_array, UdrServiceResponse.class); logger.trace("DATA UserUsage getUserUsageData...: userUsageData=" + usageDataRecords); result = predict.predict(usageDataRecords, resourceId, list_of_points); // Fit "from" and "to" fields result.setFrom(time_string_from); result.setTo(Time.MillsToString(time_to.doubleValue())); logger.trace("DATA UserUsage getUserUsageData...: userUsageData=" + gson.toJson(result)); } catch (JSONException e) { e.printStackTrace(); logger.error("EXCEPTION JSONEXCEPTION UserUsage getUserUsageData..."); } catch (IOException e) { logger.error("EXCEPTION IOEXCEPTION UserUsage getUserUsageData..."); e.printStackTrace(); } return gson.toJson(result); }
From source file:classes.Querys.java
private String sumarDias(String fecha, Integer cantidad) throws ParseException { DateTime dateTime = DateTime.parse(fecha, DateTimeFormat.forPattern("dd-MM-yyyy")); dateTime = dateTime.plusDays(cantidad); return dateTime.toString("dd-MM-yyyy"); }
From source file:cn.cuizuoli.appranking.util.DateRangeUtil.java
License:Apache License
/** * getDayListOfMonth/* w w w . j a va 2 s. co m*/ * @param month * @return */ public static List<String> getDayListOfMonth(String month) { List<String> dateList = new ArrayList<String>(); DateTime datetime = DateUtil.fromMonth(month).withDayOfMonth(1); while (StringUtils.equals(DateUtil.toMonth(datetime), month)) { dateList.add(DateUtil.toDay(datetime)); datetime = datetime.plusDays(1); } return dateList; }
From source file:cn.cuizuoli.appranking.util.DateRangeUtil.java
License:Apache License
/** * getDayList/*from ww w . ja va 2s. co m*/ * @param day * @return */ public static List<String> getDayList(String day) { List<String> dateList = new ArrayList<String>(); DateTime datetime = DateUtil.fromDay(day); for (int i = 0; i < MAX_RANGE; i++) { dateList.add(DateUtil.toDay(datetime)); datetime = datetime.plusDays(1); } return dateList; }
From source file:cn.cuizuoli.appranking.util.DateUtil.java
License:Apache License
/** * plusDays/*from w ww . j a v a2 s. c om*/ * @param day * @param days * @return */ public static String plusDays(String day, int days) { DateTime datetime = fromDay(day); return toDay(datetime.plusDays(days)); }