List of usage examples for org.joda.time LocalDate toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:cherry.foundation.type.mybatis.JodaLocalDateTypeHandler.java
License:Apache License
@Override public void setNonNullParameter(PreparedStatement ps, int i, LocalDate parameter, JdbcType jdbcType) throws SQLException { ps.setDate(i, new Date(parameter.toDate().getTime())); }
From source file:cherry.foundation.type.querydsl.LocalDateType.java
License:Apache License
@Override public void setValue(PreparedStatement st, int startIndex, LocalDate value) throws SQLException { st.setDate(startIndex, new Date(value.toDate().getTime())); }
From source file:Classes.HijriTime.java
License:Open Source License
public String getHijriTime() {////get final translated hijri date this.dayFormatter = new DecimalFormat("00"); this.yearFormatter = new DecimalFormat("0000"); Chronology iSOChronology = ISOChronology.getInstanceUTC();//get ISOChronology instance Chronology islamicChronology = IslamicChronology.getInstanceUTC();//get IslamicChronology instance LocalDate localDateISOChronology = new LocalDate(year, month, day, iSOChronology);//get local date LocalDate HijriDate = new LocalDate(localDateISOChronology.toDate(), islamicChronology);//get hijri date return hijriDaysNames[calendar.get(Calendar.DAY_OF_WEEK)] + " " + dayFormatter.format(HijriDate.getDayOfMonth()) + " " + hijriMonthsNames[HijriDate.getMonthOfYear()] + " " + yearFormatter.format(HijriDate.getYear()); }
From source file:com.aperigeek.gotadate.parser.DateParser.java
License:Open Source License
public void parse() throws DateParseException { while (token != null) { LocalDate date = null; LocalTime time = null;//www .j ava 2 s .co m try { if (isDate()) { date = parseDate(); } else if (isRelativeDate()) { date = parseRelativeDate(); } else if (isMonthName(token)) { date = parseDateMonthFirst(); } if (isTime()) { time = parseTime(); } if (date == null) { if (isDate()) { date = parseDate(); } else if (isRelativeDate()) { date = parseRelativeDate(); } else if (isMonthName(token)) { date = parseDateMonthFirst(); } } } catch (UnexpectedTokenException ex) { } finally { if (time != null) { ReadableInstant ref = (date == null) ? now : date.toDateMidnight(); DateTime dt = time.toDateTime(ref); parsed.add(dt.toDate()); } else if (date != null) { parsed.add(date.toDate()); } } next(); } }
From source file:com.axelor.apps.account.service.cfonb.CfonbExportService.java
License:Open Source License
/** * Fonction permettant de crer un enregistrement 'metteur' pour un export de prlvement de mensu * @param company/*from w w w. j av a 2 s . c o m*/ * Une socit * @param localDate * Une date * @return * Un enregistrement 'emetteur' * @throws AxelorException */ private String createSenderMonthlyExportCFONB(LocalDate localDate, BankDetails bankDetails) throws AxelorException { DateFormat ddmmFormat = new SimpleDateFormat("ddMM"); String date = ddmmFormat.format(localDate.toDateTimeAtCurrentTime().toDate()); date += String.format("%s", StringTool.truncLeft(String.format("%s", localDate.getYear()), 1)); // Rcupration des valeurs String a = this.cfonbConfig.getSenderRecordCodeExportCFONB(); // Code enregistrement String b1 = this.cfonbConfig.getDirectDebitOperationCodeExportCFONB(); // Code opration String b2 = ""; // Zone rserve String b3 = this.cfonbConfig.getSenderNumExportCFONB(); // Numro d'metteur String c1One = ""; // Zone rserve String c1Two = date; // Date d'chance String c2 = this.cfonbConfig.getSenderNameCodeExportCFONB(); // Nom/Raison sociale du donneur d'ordre String d1One = ""; // Rfrence de la remise String d1Two = ""; // Zone rserve String d2 = ""; // Zone rserve String d3 = bankDetails.getSortCode(); // Code guichet de la banque du donneur d'ordre String d4 = bankDetails.getAccountNbr(); // Numro de compte du donneur dordre String e = ""; // Zone rserve String f = ""; // Zone rserve String g1 = bankDetails.getBankCode(); // Code tablissement de la banque du donneur d'ordre String g2 = ""; // Zone rserve // Tronquage / remplissage droite (chaine de caractre) b2 = StringTool.fillStringRight(b2, ' ', 8); b3 = StringTool.fillStringRight(b3, ' ', 6); c1One = StringTool.fillStringRight(c1One, ' ', 7); c2 = StringTool.fillStringRight(c2, ' ', 24); d1One = StringTool.fillStringRight(d1One, ' ', 7); d1Two = StringTool.fillStringRight(d1Two, ' ', 17); d2 = StringTool.fillStringRight(d2, ' ', 8); d4 = StringTool.fillStringRight(d4, ' ', 11); e = StringTool.fillStringRight(e, ' ', 16); f = StringTool.fillStringRight(f, ' ', 31); g2 = StringTool.fillStringRight(g2, ' ', 6); // Tronquage / remplissage gauche (nombre) a = StringTool.fillStringLeft(a, '0', 2); b1 = StringTool.fillStringLeft(b1, '0', 2); c1Two = StringTool.fillStringLeft(c1Two, '0', 5); d3 = StringTool.fillStringLeft(d3, '0', 5); g1 = StringTool.fillStringLeft(g1, '0', 5); // Vrification AN / N / A cfonbToolService.testDigital(a, 0); cfonbToolService.testDigital(b1, 0); cfonbToolService.testDigital(d3, 0); cfonbToolService.testDigital(g1, 0); // cration de l'enregistrement return a + b1 + b2 + b3 + c1One + c1Two + c2 + d1One + d1Two + d2 + d3 + d4 + e + f + g1 + g2; }
From source file:com.axelor.apps.business.project.service.TimesheetProjectServiceImp.java
License:Open Source License
@Override public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<TimesheetLine> timesheetLineList, int priority) throws AxelorException { List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>(); int count = 0; DateFormat ddmmFormat = new SimpleDateFormat("dd/MM"); HashMap<String, Object[]> timeSheetInformationsMap = new HashMap<String, Object[]>(); //Check if a consolidation by product and user must be done boolean consolidate = generalService.getGeneral().getConsolidateTSLine(); for (TimesheetLine timesheetLine : timesheetLineList) { Object[] tabInformations = new Object[6]; tabInformations[0] = timesheetLine.getProduct(); tabInformations[1] = timesheetLine.getUser(); //Start date tabInformations[2] = timesheetLine.getDate(); //End date, useful only for consolidation tabInformations[3] = timesheetLine.getDate(); tabInformations[4] = timesheetLine.getVisibleDuration(); tabInformations[5] = timesheetLine.getProjectTask(); String key = null;// ww w .jav a2s .c om if (consolidate) { key = timesheetLine.getProduct().getId() + "|" + timesheetLine.getUser().getId() + "|" + timesheetLine.getProjectTask().getId(); if (timeSheetInformationsMap.containsKey(key)) { tabInformations = timeSheetInformationsMap.get(key); //Update date if (timesheetLine.getDate().compareTo((LocalDate) tabInformations[2]) < 0) { //If date is lower than start date then replace start date by this one tabInformations[2] = timesheetLine.getDate(); } else if (timesheetLine.getDate().compareTo((LocalDate) tabInformations[3]) > 0) { //If date is upper than end date then replace end date by this one tabInformations[3] = timesheetLine.getDate(); } tabInformations[4] = ((BigDecimal) tabInformations[4]).add(timesheetLine.getVisibleDuration()); } else { timeSheetInformationsMap.put(key, tabInformations); } } else { key = String.valueOf(timesheetLine.getId()); timeSheetInformationsMap.put(key, tabInformations); } timesheetLine.setInvoiced(true); } for (Object[] timesheetInformations : timeSheetInformationsMap.values()) { String strDate = null; Product product = (Product) timesheetInformations[0]; User user = (User) timesheetInformations[1]; LocalDate startDate = (LocalDate) timesheetInformations[2]; LocalDate endDate = (LocalDate) timesheetInformations[3]; BigDecimal visibleDuration = (BigDecimal) timesheetInformations[4]; ProjectTask projectTask = (ProjectTask) timesheetInformations[5]; if (consolidate) { strDate = ddmmFormat.format(startDate.toDate()) + " - " + ddmmFormat.format(endDate.toDate()); } else { strDate = ddmmFormat.format(startDate.toDate()); } invoiceLineList.addAll(this.createInvoiceLine(invoice, product, user, strDate, visibleDuration, priority * 100 + count)); invoiceLineList.get(0).setProject(projectTask); count++; } return invoiceLineList; }
From source file:com.axelor.apps.hr.service.timesheet.TimesheetServiceImp.java
License:Open Source License
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<TimesheetLine> timesheetLineList, int priority) throws AxelorException { List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>(); int count = 0; DateFormat ddmmFormat = new SimpleDateFormat("dd/MM"); HashMap<String, Object[]> timeSheetInformationsMap = new HashMap<String, Object[]>(); //Check if a consolidation by product and user must be done boolean consolidate = generalService.getGeneral().getConsolidateTSLine(); for (TimesheetLine timesheetLine : timesheetLineList) { Object[] tabInformations = new Object[5]; tabInformations[0] = timesheetLine.getProduct(); tabInformations[1] = timesheetLine.getUser(); //Start date tabInformations[2] = timesheetLine.getDate(); //End date, useful only for consolidation tabInformations[3] = timesheetLine.getDate(); tabInformations[4] = timesheetLine.getVisibleDuration(); String key = null;//from w w w .ja v a 2 s.co m if (consolidate) { key = timesheetLine.getProduct().getId() + "|" + timesheetLine.getUser().getId(); if (timeSheetInformationsMap.containsKey(key)) { tabInformations = timeSheetInformationsMap.get(key); //Update date if (timesheetLine.getDate().compareTo((LocalDate) tabInformations[2]) < 0) { //If date is lower than start date then replace start date by this one tabInformations[2] = timesheetLine.getDate(); } else if (timesheetLine.getDate().compareTo((LocalDate) tabInformations[3]) > 0) { //If date is upper than end date then replace end date by this one tabInformations[3] = timesheetLine.getDate(); } tabInformations[4] = ((BigDecimal) tabInformations[4]).add(timesheetLine.getVisibleDuration()); } else { timeSheetInformationsMap.put(key, tabInformations); } } else { key = String.valueOf(timesheetLine.getId()); timeSheetInformationsMap.put(key, tabInformations); } timesheetLine.setInvoiced(true); } for (Object[] timesheetInformations : timeSheetInformationsMap.values()) { String strDate = null; Product product = (Product) timesheetInformations[0]; User user = (User) timesheetInformations[1]; LocalDate startDate = (LocalDate) timesheetInformations[2]; LocalDate endDate = (LocalDate) timesheetInformations[3]; BigDecimal visibleDuration = (BigDecimal) timesheetInformations[4]; if (consolidate) { strDate = ddmmFormat.format(startDate.toDate()) + " - " + ddmmFormat.format(endDate.toDate()); } else { strDate = ddmmFormat.format(startDate.toDate()); } invoiceLineList.addAll(this.createInvoiceLine(invoice, product, user, strDate, visibleDuration, priority * 100 + count)); count++; } return invoiceLineList; }
From source file:com.axelor.apps.hr.service.timesheet.TimesheetServiceImpl.java
License:Open Source License
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<TimesheetLine> timesheetLineList, int priority) throws AxelorException { List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>(); int count = 0; DateFormat ddmmFormat = new SimpleDateFormat("dd/MM"); HashMap<String, Object[]> timeSheetInformationsMap = new HashMap<String, Object[]>(); //Check if a consolidation by product and user must be done boolean consolidate = generalService.getGeneral().getConsolidateTSLine(); for (TimesheetLine timesheetLine : timesheetLineList) { Object[] tabInformations = new Object[5]; tabInformations[0] = timesheetLine.getProduct(); tabInformations[1] = timesheetLine.getUser(); //Start date tabInformations[2] = timesheetLine.getDate(); //End date, useful only for consolidation tabInformations[3] = timesheetLine.getDate(); tabInformations[4] = timesheetLine.getDurationStored(); String key = null;// w w w . j ava2 s.c om if (consolidate) { key = timesheetLine.getProduct().getId() + "|" + timesheetLine.getUser().getId(); if (timeSheetInformationsMap.containsKey(key)) { tabInformations = timeSheetInformationsMap.get(key); //Update date if (timesheetLine.getDate().compareTo((LocalDate) tabInformations[2]) < 0) { //If date is lower than start date then replace start date by this one tabInformations[2] = timesheetLine.getDate(); } else if (timesheetLine.getDate().compareTo((LocalDate) tabInformations[3]) > 0) { //If date is upper than end date then replace end date by this one tabInformations[3] = timesheetLine.getDate(); } tabInformations[4] = ((BigDecimal) tabInformations[4]).add(timesheetLine.getDurationStored()); } else { timeSheetInformationsMap.put(key, tabInformations); } } else { key = String.valueOf(timesheetLine.getId()); timeSheetInformationsMap.put(key, tabInformations); } timesheetLine.setInvoiced(true); } for (Object[] timesheetInformations : timeSheetInformationsMap.values()) { String strDate = null; Product product = (Product) timesheetInformations[0]; User user = (User) timesheetInformations[1]; LocalDate startDate = (LocalDate) timesheetInformations[2]; LocalDate endDate = (LocalDate) timesheetInformations[3]; BigDecimal durationStored = (BigDecimal) timesheetInformations[4]; if (consolidate) { strDate = ddmmFormat.format(startDate.toDate()) + " - " + ddmmFormat.format(endDate.toDate()); } else { strDate = ddmmFormat.format(startDate.toDate()); } invoiceLineList.addAll(this.createInvoiceLine(invoice, product, user, strDate, durationStored, priority * 100 + count)); count++; } return invoiceLineList; }
From source file:com.bgh.myopeninvoice.jsf.jsfbeans.InvoiceBean.java
License:Apache License
public String onFlowProcessTimesheet(FlowEvent event) { //this is to reset position and adjust based on the size of data RequestContext.getCurrentInstance().execute("PF('invoice-items-timesheet-form-dialog').initPosition();"); if ("select-date".equalsIgnoreCase(event.getOldStep()) && selectedInvoiceItemsEntity != null) { //need to reset in case we changed something selectedInvoiceItemsEntity = invoiceDAO.getInvoiceItemsRepository() .findOne(selectedInvoiceItemsEntity.getInvoiceItemId()); final List<TimeSheetEntity> timeSheetsByInvoiceItemId = (List<TimeSheetEntity>) selectedInvoiceItemsEntity .getTimeSheetsByInvoiceItemId(); int days = Days.daysBetween(dateFromTimesheet, dateToTimesheet).getDays() + 1; for (int i = 0; i < days; i++) { LocalDate potentialLocalDate = dateFromTimesheet.withFieldAdded(DurationFieldType.days(), i); TimeSheetEntity e = new TimeSheetEntity(); e.setInvoiceItemId(selectedInvoiceItemsEntity.getInvoiceItemId()); e.setInvoiceItemsByInvoiceItemId(selectedInvoiceItemsEntity); e.setItemDate(potentialLocalDate.toDate()); if (timeSheetsByInvoiceItemId.stream() .noneMatch(p -> p.getItemDate().equals(potentialLocalDate.toDate()))) { timeSheetsByInvoiceItemId.add(e); }/*from w w w.java 2 s.co m*/ } //need to sort here because we added some values - they will be displayed in order timeSheetsByInvoiceItemId.sort((l1, l2) -> l1.getItemDate().compareTo(l2.getItemDate())); } return event.getNewStep(); }
From source file:com.creditcloud.carinsurance.CarInsuranceRepaymentServiceBean.java
/** * /*from w ww . j a v a2s.co m*/ * * @param clientCode * @param from * @param to * @param pageInfo * @param status * @return */ @Override public PagedResult<CarInsuranceRepaymentModel> listDueRepay(String clientCode, LocalDate from, LocalDate to, PageInfo pageInfo, CarInsuranceStatus... status) { appBean.checkClientCode(clientCode); logger.debug("listDueRepay.[clientCode={}][from={}][to={}][pageInfo={}][status={}]", clientCode, from, to, pageInfo, Arrays.asList(status)); PagedResult<CarInsuranceRepayment> repayments = carInsuranceRepaymentDAO.listDueRepay(from.toDate(), to.toDate(), pageInfo, status); List<CarInsuranceRepaymentModel> result = new ArrayList<>(repayments.getResults().size()); for (CarInsuranceRepayment repayment : repayments.getResults()) { User user = userService.findByUserId(appBean.getClientCode(), repayment.getCarInsurance().getUserId()); CarInsuranceRepaymentModel model = CarInsuranceDTOUtils.convertCarInsuranceRepaymentDTO(repayment, user); result.add(model); } return new PagedResult<>(result, repayments.getTotalSize()); }