List of usage examples for java.util Date getMonth
@Deprecated public int getMonth()
From source file:com.mimp.controllers.personal.java
@RequestMapping(value = "/logParticularFiltroHoy", method = RequestMethod.GET) public ModelAndView logParticularFiltroHoy_GET(ModelMap map, HttpSession session) { Personal usuario = (Personal) session.getAttribute("usuario"); if (usuario == null) { String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente"; map.addAttribute("mensaje", mensaje); return new ModelAndView("login", map); }/*from w w w.j av a2 s. c om*/ long idpersonal = Long.parseLong(session.getAttribute("id").toString()); //List<Personal> lista = Servicio.listaPersonal(); Date diatemp = new Date(); String dia = String.valueOf(diatemp.getDate()) + "/" + String.valueOf(diatemp.getMonth() + 1) + "/" + String.valueOf(diatemp.getYear() + 1900); Personal personal = new Personal(); personal = ServicioPersonal.getPersonal(idpersonal); map.put("listaParticularLog", ServicioPersonal.getLogParticularPorDia(idpersonal, dia)); map.put("user", personal); map.put("dia", dia); return new ModelAndView("/Personal/registros/usuarios/log_particular", map); }
From source file:com.mss.msp.util.DataSourceDataProvider.java
public String createFileInFileSystem(String filePath, String fileName, File file, String privateKey) throws Exception { File theFile = null;//from w w w .j a va 2 s . c om try { File createPath = new File(filePath); Date dt = new Date(); /* The month is generated from here */ String month = ""; if (dt.getMonth() == 0) { month = "Jan"; } else if (dt.getMonth() == 1) { month = "Feb"; } else if (dt.getMonth() == 2) { month = "Mar"; } else if (dt.getMonth() == 3) { month = "Apr"; } else if (dt.getMonth() == 4) { month = "May"; } else if (dt.getMonth() == 5) { month = "Jun"; } else if (dt.getMonth() == 6) { month = "Jul"; } else if (dt.getMonth() == 7) { month = "Aug"; } else if (dt.getMonth() == 8) { month = "Sep"; } else if (dt.getMonth() == 9) { month = "Oct"; } else if (dt.getMonth() == 10) { month = "Nov"; } else if (dt.getMonth() == 11) { month = "Dec"; } short week = (short) (Math.round(dt.getDate() / 7)); // createPath = new File(createPath.getAbsolutePath() + "/" + // String.valueOf(dt.getYear() + 1900) + "/" + month + "/" + // String.valueOf(week)); createPath = new File( createPath.getAbsolutePath() + File.separator + String.valueOf(dt.getYear() + 1900) + File.separator + month + File.separator + String.valueOf(week)); createPath.mkdirs(); /* * here it takes the absolute path and the name of the file that is * to be uploaded */ theFile = new File(createPath.getAbsolutePath()); // setConsultantResumeFilePath(theFile.toString()); /* copies the file to the destination */ // File destFile = new File(theFile + File.separator + filePath); // System.out.println("fileName--->"+fileName); File destFile = new File(theFile + File.separator + fileName); String aesKeyString = Properties.getProperty("AES_KEY"); // System.out.println("filePath--->"+filePath); // System.out.println("privateKey--"+privateKey); // privateKey="LaIIBJuQfjfFrPUrj+rgwg=="; // System.out.println("privateKey after--"+privateKey); SecurityServiceProvider.encryptFileUsingAES(aesKeyString, file, destFile); // System.out.println("theFile.toString()--->"+theFile.toString()); } catch (Exception ex) { ex.printStackTrace(); System.out.println("Error in Catch of createFileInFileSystem --->" + ex.getMessage()); // TODO: handle exception } // FileUtils.copyFile(file, destFile); return theFile.toString(); }
From source file:com.nec.harvest.controller.SuihController.java
/** * Calculator total data 12 month and fill 3 month of quarter * // w w w . j av a 2 s .c om * @param listSuisYear * Data profit and loss * @param monthly * month * @param businessDay * a day business * @param mapBudgetPerformance * Map at023 * @param mapInventory * Map at015 * @param quarter * a current quarter * @param model */ private void calculateSuih(Map<String, List<VJiseki>> mapSuisYear, Date monthly, Date businessDay, Map<String, BudgetPerformanceBean> mapBudgetPerformance, Map<String, Double> mapInventory, int quarter, Model model) { logger.info("Begin calculator suih for 3 month and total of year"); final String TOTAL_QUARTER = "totalQuarter"; Integer no12 = null; // _??__?? Integer no14 = null; // _?__??) Integer no16 = null; // ___?? Integer no18 = null; // _??__?? Integer no20 = null; // ___?? Integer no22 = null; // _?__?? Integer no25 = null; // ___?? Double no26 = null; // ___ Integer no29 = null; // __?? Double no30 = null; // __ Integer no33 = null; // __?? Double no34 = null; // __ Integer no37 = null; // __?? Double no38 = null; // __ int index = 0; SuisMonthBean suisMonthly = null; String valueBlank = "1"; if (mapSuisYear != null && mapSuisYear.size() > 0) { for (Map.Entry<String, List<VJiseki>> entry : mapSuisYear.entrySet()) { String key = entry.getKey(); List<VJiseki> listJiseki = entry.getValue(); try { String getsudo = key; Date yearmonth = DateFormatUtil.parse(getsudo, DateFormat.DATE_WITHOUT_DAY); double taxRate = 0d; try { taxRate = consumptionTaxRateService.findActualTaxRateByDate(yearmonth); } catch (IllegalArgumentException | ObjectNotFoundException ex) { logger.warn(ex.getMessage()); } catch (ServiceException ex) { logger.error(ex.getMessage(), ex); // ??????????? model.addAttribute(ERROR_MESSAGE, getSystemError()); model.addAttribute(ERROR, true); } Integer no11 = null; // _??_n1n3_? Integer no15 = null; // __n1n3_???? Integer no13 = null; // _?_n1n3_? Integer no17 = null; // _??_n1n3_?? Integer no19 = null; // __n1n3_?? Integer no21 = null; // _?_n1n3_?? Integer no23 = null; // __n1n3_?? Double no24 = null; // __n1n3_ Integer no27 = null; // _n1n3_?? Double no28 = null; // _n1n3_ Integer no31 = null; // _n1n3_?? Double no32 = null; // _n1n3_ Integer no35 = null; // _n1n3_?? Double no36 = null; // _n1n3_ Double no19Percent = null; if (yearmonth.after(monthly)) { int days = DateUtil.getNumberOfDays(yearmonth, businessDay); if (CollectionUtils.isNotEmpty(listJiseki)) { for (VJiseki jiseki : listJiseki) { // for list together month int tmp = 0; String strValueBlank = ""; int daysInMonth = DateUtil.getActualMaximumOfMonth(businessDay); logger.info("Total days of month {} ", daysInMonth); // // NO11 ???????? ? ????? ??1,000?????? // if (jiseki.getUriSkKG() != null) { // double uriSkKG = jiseki.getUriSkKG().doubleValue(); // tmp = (int) Math.floor((uriSkKG - Math.floor(uriSkKG / (100 + taxRate) * taxRate)) / 1000); // no11 = (no11 == null) ? 0 : no11.intValue(); // no11 = no11 + tmp; // } // Modified by SONDN 2014/12/22: Update SPEC 20141222 // NO11 ???????? ? ????? ??1,000?????? if (jiseki.getUriSkKG() != null || jiseki.getKtSkKG() != null || jiseki.getIdoSkKGU() != null || jiseki.getIdoSkKGH() != null) { Double uriSkKG = jiseki.getUriSkKG(); Double ktSkKG = jiseki.getKtSkKG(); Double idoSkKGU = jiseki.getIdoSkKGU(); Double idoSkKGH = jiseki.getIdoSkKGH(); double step1 = uriSkKG == null ? 0 : uriSkKG - Math.floor((uriSkKG / (100 + taxRate)) * taxRate); double step2 = ktSkKG == null ? 0 : ktSkKG; int tmpDays = DateUtil.getNumberOfDays(yearmonth, businessDay); if (tmpDays > 0) { step2 = (step2 / daysInMonth) * tmpDays; } double step3 = idoSkKGU == null ? 0 : idoSkKGU; double step4 = idoSkKGH == null ? 0 : idoSkKGH; tmp = (int) Math.floor((step1 + step2 + step3 - step4) / 1000); no11 = (no11 == null) ? 0 : no11.intValue(); no11 = no11 + tmp; } // (1) ? ???? double temp1 = 0d; if (jiseki.getUriKrKG() != null) { double uriKrKG = jiseki.getUriKrKG().doubleValue(); temp1 = Math.floor(uriKrKG - Math.floor(uriKrKG / (100 + taxRate) * taxRate)); } else { strValueBlank = strValueBlank.concat(valueBlank);// 1 } // (2) ? ??? double temp2 = 0d; if (jiseki.getKtKrKG() != null) { temp2 = jiseki.getKtKrKG().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 11 } if (days > 0) { temp1 = (temp1 / daysInMonth) * days; temp2 = (temp2 / daysInMonth) * days; } else if (days == 0) { strValueBlank = "11"; } // NO13 ????????(1) + (2) if (!strValueBlank.equals("11")) { no13 = (no13 == null) ? 0 : no13.intValue(); tmp = (int) Math.floor((temp1 + temp2) / 1000); no13 = no13 + tmp; } // ???????? strValueBlank = ""; double ktsrkg = 0d; // (1) ? ? if (jiseki.getKtSrKG() != null) { ktsrkg = jiseki.getKtSrKG().doubleValue(); if (days >= 0) { ktsrkg = (ktsrkg / daysInMonth) * days; } } else { strValueBlank = strValueBlank.concat(valueBlank);// 1 } // (2) ? ?? double kgcSrKG = 0d; if (jiseki.getKgcSrKG() != null) { kgcSrKG = jiseki.getKgcSrKG().doubleValue(); kgcSrKG = Math.floor(kgcSrKG - Math.floor(kgcSrKG / (100 + taxRate) * taxRate)); } else { strValueBlank = strValueBlank.concat(valueBlank);// 11 } // (3) ? ?????? double idoSrkGU = 0d; if (jiseki.getIdoSrKGU() != null) { idoSrkGU = jiseki.getIdoSrKGU().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 111 } // (4) ? ?? double idoSrkGH = 0d; if (jiseki.getIdoSrKGH() != null) { idoSrkGH = jiseki.getIdoSrKGH().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 1111 } // (5) ? ? double knSrKG = 0d; if (jiseki.getKnSrKG() != null) { knSrKG = jiseki.getKnSrKG().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 11111 } // (1) + (2) + (3) + (4) - (5) if (!strValueBlank.equals("11111")) { tmp = (int) Math .floor((knSrKG + ktsrkg + kgcSrKG + idoSrkGU - idoSrkGH) / 1000); no19 = (no19 == null) ? 0 : no19.intValue(); no19 = no19 + tmp; } // NO27 ???????? strValueBlank = ""; // (1) ? ?? double ktJkKG = 0d; if (jiseki.getKtJkKG() != null) { ktJkKG = jiseki.getKtJkKG().doubleValue(); if (days >= 0) { ktJkKG = (ktJkKG / daysInMonth) * days; } } else { strValueBlank = strValueBlank.concat(valueBlank);// 1 } // (2) ? ? double jkJkKG = 0d; if (jiseki.getJkJkKG() != null) { jkJkKG = jiseki.getJkJkKG().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 11 } // (3) ? ?????? double kgcJkKG = 0d; if (jiseki.getKgcJkKG() != null) { kgcJkKG = jiseki.getKgcJkKG().doubleValue(); kgcJkKG = Math.floor(kgcJkKG - Math.floor(kgcJkKG / (100 + taxRate) * taxRate)); } else { strValueBlank = strValueBlank.concat(valueBlank);// 111 } // (4) ? ?? double idoJkKGU = 0d; if (jiseki.getIdoJkKGU() != null) { idoJkKGU = jiseki.getIdoJkKGU().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 1111 } // (5) ? ? double idoJkKGH = 0d; if (jiseki.getIdoJkKGH() != null) { idoJkKGH = jiseki.getIdoJkKGH().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 11111 } // (6) ? ?? double helpJkKGU = 0d; if (jiseki.getHelpJkKGU() != null) { helpJkKGU = jiseki.getHelpJkKGU().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 111111 } // (7) ? ? double helpJkKGH = 0d; if (jiseki.getHelpJkKGH() != null) { helpJkKGH = jiseki.getHelpJkKGH().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 1111111 } // (1) + (2) + (3) + (4) - (5) + (6) - (7) if (!strValueBlank.equals("1111111")) { tmp = (int) Math.floor((ktJkKG + jkJkKG + kgcJkKG + idoJkKGU - idoJkKGH + helpJkKGU - helpJkKGH) / 1000); no27 = (no27 == null) ? 0 : no27.intValue(); no27 = no27 + tmp; } // NO31 ???????? // (1) ? ?? strValueBlank = ""; double ktKhKG = 0d; if (jiseki.getKtKhKG() != null) { ktKhKG = jiseki.getKtKhKG().doubleValue(); if (days >= 0) { ktKhKG = ktKhKG / daysInMonth * days; } } else { strValueBlank = strValueBlank.concat(valueBlank);// 1 } // (2) ? ? double knKhKG = 0d; if (jiseki.getKnKhKG() != null) { knKhKG = jiseki.getKnKhKG().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 11 } // (3) ? ?????? double kgcKhKG = 0d; if (jiseki.getKgcKhKG() != null) { kgcKhKG = jiseki.getKgcKhKG().doubleValue(); kgcKhKG = Math.floor(kgcKhKG - Math.floor(kgcKhKG / (100 + taxRate) * taxRate)); } else { strValueBlank = strValueBlank.concat(valueBlank);// 111 } // (4) ? ?? double idoKhKGU = 0d; if (jiseki.getIdoKhKGU() != null) { idoKhKGU = jiseki.getIdoKhKGU().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 1111 } // (5) ? ? double idoKhKGH = 0d; if (jiseki.getIdoKhKGH() != null) { idoKhKGH = jiseki.getIdoKhKGH().doubleValue(); } else { strValueBlank = strValueBlank.concat(valueBlank);// 11111 } // (6) ? ?? double uriKhKG = 0d; if (jiseki.getUriKhKG() != null) { uriKhKG = jiseki.getUriKhKG().doubleValue(); uriKhKG = Math.floor(uriKhKG - Math.floor(uriKhKG / (100 + taxRate) * taxRate)); if (days >= 0) { uriKhKG = uriKhKG / daysInMonth * days; } } else { strValueBlank = strValueBlank.concat(valueBlank);// 111111 } // (1) + (2) + (3) + (4) - (5) + (6) if (!strValueBlank.equals("111111")) { tmp = (int) Math.floor( (ktKhKG + knKhKG + kgcKhKG + idoKhKGU - idoKhKGH + uriKhKG) / 1000); no31 = (no31 == null) ? 0 : no31.intValue(); no31 = no31 + tmp; } } // end for together monthly // NO12 ??????_??_??? ??1,000?????? if (no11 != null) { no12 = (no12 == null) ? 0 : no12.intValue(); no12 += no11; } // NO14 ??????_?_??? ??1,000?????? if (no13 != null) { no14 = (no14 == null) ? 0 : no14.intValue(); no14 += no13; } // NO15 ???????? _??__??? _?__??? ??1,000??????2 if (no11 != null || no13 != null) { int temp11 = (no11 == null) ? 0 : no11.intValue(); int temp13 = (no13 == null) ? 0 : no13.intValue(); no15 = (no15 == null) ? 0 : no15.intValue(); no15 = temp11 + temp13; } // NO19/NO11 if (no19 != null && (no11 != null && no11.intValue() > 0)) { no19Percent = RoundNumericUtil.roundSonekiSuii(no19, no11); } } // NO21 ????????? ???????? ??1,000?????? Double amount = (mapInventory != null) ? mapInventory.get(getsudo) : null; if (amount != null && amount.doubleValue() != -1) { no21 = (int) amount.doubleValue() / 1000; } // NO17 ?????????????????? ??1,000?????? if (no21 != null) { int previousGetSudo = Integer.parseInt(DateFormatUtil .format(DateUtil.monthsToSubtract(yearmonth, 1), DateFormat.DATE_WITHOUT_DAY)); Double temp = (mapInventory != null) ? (Double) mapInventory.get(String.valueOf(previousGetSudo)) : null; if (temp != null && temp.doubleValue() != -1) { // Change SPEC 01/09/2014 if (days != -1 && no21 == 0) { no17 = null; no21 = null; } else { no17 = (int) (temp.doubleValue() / 1000); } // End change SPEC 01/09/2014 } } // Modified by SONDN 2014/12/23: Update SPEC 20141222 // NO17 ?????0????????????? if (yearmonth.getYear() == businessDay.getYear() && yearmonth.getMonth() == businessDay.getMonth() && (no21 == null || no21 == 0)) { no17 = null; } // (NO23) _??_n_??__n_??-_?_n_?? if (no17 != null || no19 != null || no21 != null) { int temp17 = (no17 == null) ? 0 : no17.intValue(); int temp19 = (no19 == null) ? 0 : no19.intValue(); int temp21 = (no21 == null) ? 0 : no21.intValue(); no23 = temp17 + temp19 - temp21; } // NO35 ???????? ___???___???__???__?? if (no15 != null || no23 != null || no27 != null || no31 != null) { int temp15 = (no15 == null) ? 0 : no15.intValue(); int temp23 = (no23 == null) ? 0 : no23.intValue(); int temp27 = (no27 == null) ? 0 : no27.intValue(); int temp31 = (no31 == null) ? 0 : no31.intValue(); no35 = temp15 - temp23 - temp27 - temp31; } } else { if (mapBudgetPerformance != null) { // (N015) ??????????? ? =??? BudgetPerformanceBean kingaku = (BudgetPerformanceBean) mapBudgetPerformance .get(getsudo + Constants.DEFAULT_KMKCODEJ_K7111); if (kingaku != null && kingaku.getJisekiKingaku() != null) { no15 = (int) Math.floor(kingaku.getJisekiKingaku().doubleValue() / 1000); } // (NO19) ??????????? ? =??? kingaku = (BudgetPerformanceBean) mapBudgetPerformance .get(getsudo + Constants.DEFAULT_KMKCODEJ_K7521); if (kingaku != null && kingaku.getJisekiKingaku() != null) { no19 = (int) Math.floor(kingaku.getJisekiKingaku().doubleValue() / 1000); } // (NO27) ???????????? =??? kingaku = (BudgetPerformanceBean) mapBudgetPerformance .get(getsudo + Constants.DEFAULT_KMKCODEJ_K8110); if (kingaku != null && kingaku.getJisekiKingaku() != null) { no27 = (int) Math.floor(kingaku.getJisekiKingaku().doubleValue() / 1000); } // (NO31) ??????????? ? =??? kingaku = (BudgetPerformanceBean) mapBudgetPerformance .get(getsudo + Constants.DEFAULT_KMKCODEJ_K8210); if (kingaku != null && kingaku.getJisekiKingaku() != null) { no31 = (int) Math.floor(kingaku.getJisekiKingaku().doubleValue() / 1000); } // NO 35 ???????????? =??? kingaku = (BudgetPerformanceBean) mapBudgetPerformance .get(getsudo + Constants.DEFAULT_KMKCODEJ_K8310); if (kingaku != null && kingaku.getJisekiKingaku() != null) { no35 = (int) Math.floor(kingaku.getJisekiKingaku().doubleValue() / 1000); } } // (NO23) _??_n_??__n_??-_?_n_?? if (no17 != null || no19 != null || no21 != null) { int temp17 = (no17 == null) ? 0 : no17.intValue(); int temp19 = (no19 == null) ? 0 : no19.intValue(); int temp21 = (no21 == null) ? 0 : no21.intValue(); no23 = temp17 + temp19 - temp21; } } if (no15 != null && no15.intValue() > 0) { //(NO24) __n_???__n_?? ??? if (no23 != null) { no24 = RoundNumericUtil.roundSonekiSuii(no23, no15); } // (NO28) _n_???__n_?? ??? if (no27 != null) { no28 = RoundNumericUtil.roundSonekiSuii(no27, no15); } // (NO32) _n_???__n_?? ??? if (no31 != null) { no32 = RoundNumericUtil.roundSonekiSuii(no31, no15); } // (NO36) _n_???__n_?? ??? if (no35 != null) { no36 = RoundNumericUtil.roundSonekiSuii(no35, no15); } } int currentQuarter = Integer.parseInt(DateUtil.getQuarter(yearmonth)) - 1; if (currentQuarter == 0) { currentQuarter = 4; } // ?? if (quarter == currentQuarter) { suisMonthly = new SuisMonthBean(no11, no13, no15, no17, no19, no21, no23, no24, no27, no28, no31, no32, no35, no36, no19Percent); setDataMonthly(index, suisMonthly, model); logger.info("??"); index++; } // ?? (NO16, NO18, NO20, NO22, NO24, NO29, NO33) if (no15 != null) { no16 = (no16 == null) ? 0 : no16.intValue(); no16 += no15; } if (no17 != null) { no18 = (no18 == null) ? 0 : no18.intValue(); no18 += no17; } if (no19 != null) { no20 = (no20 == null) ? 0 : no20.intValue(); no20 += no19; } if (no21 != null) { no22 = (no22 == null) ? 0 : no22.intValue(); no22 += no21; } if (no27 != null) { no29 = (no29 == null) ? 0 : no29.intValue(); no29 += no27; } if (no31 != null) { no33 = (no33 == null) ? 0 : no33.intValue(); no33 += no31; } if (no35 != null) { no37 = (no37 == null) ? 0 : no37.intValue(); no37 += no35; } } catch (NullPointerException | IllegalArgumentException | ParseException ex) { logger.warn(ex.getMessage()); } // (NO21) _??_n_??__n_??-_?_n_?? if (no18 != null || no20 != null || no22 != null) { int temp18 = (no18 == null) ? 0 : no18.intValue(); int temp20 = (no20 == null) ? 0 : no20.intValue(); int temp22 = (no22 == null) ? 0 : no22.intValue(); no25 = temp18 + temp20 - temp22; } if (no16 != null && no16.intValue() > 0) { // (NO22) ___???___?? ??? if (no25 != null) { no26 = RoundNumericUtil.roundSonekiSuii(no25, no16); } // (NO26) __???___?? ??? if (no29 != null) { no30 = RoundNumericUtil.roundSonekiSuii(no29, no16); } // (NO30) __???___?? ??? if (no33 != null) { no34 = RoundNumericUtil.roundSonekiSuii(no33, no16); } // (NO34) __???___?? ??? if (no37 != null) { no38 = RoundNumericUtil.roundSonekiSuii(no37, no16); } } } } // ?? SuisTotalBean suisTotal = new SuisTotalBean(no12, no14, no16, no18, no20, no22, no25, no26, no29, no30, no33, no34, no37, no38); model.addAttribute(TOTAL_QUARTER, suisTotal); // Log calculator finished logger.info("End calculator suih for 3 month and total of year"); }