List of usage examples for java.time LocalDate parse
public static LocalDate parse(CharSequence text, DateTimeFormatter formatter)
From source file:com.qq.tars.service.monitor.TARSPropertyMonitorCondition.java
public TARSPropertyMonitorCondition(HttpServletRequest request) { thedate = StringUtils.trimToNull(request.getParameter("thedate")); predate = StringUtils.trimToNull(request.getParameter("predate")); theshowtime = StringUtils.trimToNull(request.getParameter("theshowtime")); preshowtime = StringUtils.trimToNull(request.getParameter("preshowtime")); masterName = StringUtils.trimToNull(request.getParameter("master_name")); masterIp = StringUtils.trimToNull(request.getParameter("master_ip")); propertyName = StringUtils.trimToNull(request.getParameter("property_name")); policy = StringUtils.trimToNull(request.getParameter("policy")); groupBy = StringUtils.trimToNull(request.getParameter("group_by")); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); if (null == thedate) { thedate = LocalDate.now().format(formatter); }//w w w . j a va2s . c om if (null == predate) { predate = LocalDate.parse(thedate, formatter).plusDays(-1).format(formatter); } if (null == theshowtime) { theshowtime = "0000"; } if (null == preshowtime) { preshowtime = "2360"; } }
From source file:net.tradelib.core.Series.java
static public Series fromCsv(String path, boolean header, DateTimeFormatter dtf, LocalTime lt) throws Exception { if (dtf == null) { if (lt == null) dtf = DateTimeFormatter.ISO_LOCAL_DATE_TIME; else//from www .j a va 2s. c o m dtf = DateTimeFormatter.ISO_DATE; } // Parse and import the csv CSVFormat csvFmt = CSVFormat.DEFAULT.withCommentMarker('#').withIgnoreSurroundingSpaces(); if (header) csvFmt = csvFmt.withHeader(); CSVParser csv = csvFmt.parse(new BufferedReader(new FileReader(path))); int ncols = -1; Series result = null; double[] values = null; for (CSVRecord rec : csv.getRecords()) { if (result == null) { ncols = rec.size() - 1; values = new double[ncols]; result = new Series(ncols); } for (int ii = 0; ii < ncols; ++ii) { values[ii] = Double.parseDouble(rec.get(ii + 1)); } LocalDateTime ldt; if (lt != null) { ldt = LocalDate.parse(rec.get(0), dtf).atTime(lt); } else { ldt = LocalDateTime.parse(rec.get(0), dtf); } result.append(ldt, values); } if (header) { Map<String, Integer> headerMap = csv.getHeaderMap(); result.clearNames(); for (Map.Entry<String, Integer> me : headerMap.entrySet()) { if (me.getValue() > 0) result.setName(me.getKey(), me.getValue() - 1); } } return result; }
From source file:org.jbb.members.web.base.logic.MemberSearchCriteriaFactory.java
private LocalDate getJoinDate(SearchMemberForm form) { try {//from w w w. j av a2 s.c o m return StringUtils.isNotBlank(form.getJoinedDate()) ? LocalDate.parse(form.getJoinedDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")) : null; } catch (DateTimeParseException e) { log.trace("Date time parsing error", e); throw new MemberSearchJoinDateFormatException(); } }
From source file:com.qq.tars.service.monitor.TARSStatMonitorCondition.java
public TARSStatMonitorCondition(HttpServletRequest request) { thedate = StringUtils.trimToNull(request.getParameter("thedate")); predate = StringUtils.trimToNull(request.getParameter("predate")); theshowtime = StringUtils.trimToNull(request.getParameter("theshowtime")); preshowtime = StringUtils.trimToNull(request.getParameter("preshowtime")); masterName = StringUtils.trimToNull(request.getParameter("master_name")); slaveName = StringUtils.trimToNull(request.getParameter("slave_name")); interfaceName = StringUtils.trimToNull(request.getParameter("interface_name")); masterIp = StringUtils.trimToNull(request.getParameter("master_ip")); slaveIp = StringUtils.trimToNull(request.getParameter("slave_ip")); groupBy = StringUtils.trimToNull(request.getParameter("group_by")); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); if (null == thedate) { thedate = LocalDate.now().format(formatter); }// w ww . j a va 2 s . c om if (null == predate) { predate = LocalDate.parse(thedate, formatter).plusDays(-1).format(formatter); } if (null == theshowtime) { theshowtime = "0000"; } if (null == preshowtime) { preshowtime = "2360"; } }
From source file:svc.data.citations.datasources.mock.MockCitationDataSourceIntegrationTest.java
@Test public void GetCitationsByDOBAndLastNameAndMunicipalitiesSuccessful() throws ParseException { String dateString = "05/18/1987"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy"); LocalDate date = LocalDate.parse(dateString, formatter); List<Long> municipalities = Lists.newArrayList(33L, 44L); List<Citation> citations = mockCitationDataSource.getByNameAndMunicipalitiesAndDOB("Peterson", municipalities, date);//from ww w. j av a2s . com assertThat(citations, is(notNullValue())); assertThat(citations.size(), is(2)); assertThat(citations.get(0).first_name, is("Brenda")); }
From source file:fi.csc.emrex.smp.model.Person.java
public void setBirthDate(String birthDate, String dateFormat) { dateFormatter = DateTimeFormatter.ofPattern(dateFormat); if (birthDate == null || dateFormat == null) { this.birthDate = null; } else {/*from w w w .j ava2 s .c o m*/ this.birthDate = LocalDate.parse(birthDate, dateFormatter); } }
From source file:svc.data.citations.datasources.tyler.transformers.CitationTransformer.java
public Citation fromTylerCitation(TylerCitation tylerCitation) { if (tylerCitation == null) { return null; }/*from w w w .j a v a 2 s .c o m*/ Citation genericCitation = new Citation(); genericCitation.citation_number = tylerCitation.citationNumber; genericCitation.first_name = tylerCitation.firstName; genericCitation.last_name = tylerCitation.lastName; genericCitation.drivers_license_number = tylerCitation.driversLicenseNumber; if (tylerCitation.dob == null) { LogSystem.LogEvent("Received tyler citation with no DOB."); } else { genericCitation.date_of_birth = LocalDate.parse(tylerCitation.dob, localDateFormatter); } if (tylerCitation.violationDate == null) { LogSystem.LogEvent("Received tyler citation with no violation date."); } else { genericCitation.citation_date = LocalDate.parse(tylerCitation.violationDate, localDateFormatter); } if (tylerCitation.violations == null) { LogSystem.LogEvent("No violations received with Tyler citation. Skipping fields that require them."); } else { List<LocalDateTime> violationCourtDates = null; violationCourtDates = tylerCitation.violations.stream().map((violation) -> violation.courtDate) .distinct().map(this::parseViolationCourtDate).collect(Collectors.toList()); genericCitation.court_dateTime = violationCourtDates.size() > 0 ? violationCourtDates.get(0) : null; genericCitation.violations = violationTransformer.fromTylerCitation(tylerCitation); String tylerCourtIdentifier = getTylerCourtIdentifier(tylerCitation); genericCitation.court_id = courtIdTransformer.lookupCourtId(tylerCourtIdentifier); genericCitation.municipality_id = municipalityIdTransformer .lookupMunicipalityId(CITATION_DATASOURCE.TYLER, "County"); } // These could probably be added to the Tyler API // citation time? // Boolean mandatory_court_apperarnce // Boolean can_pay_online // public String defendant_address; - not in Tyler API // public String defendant_city; - not in Tyler API // public String defendant_state; - not in Tyler API // There is no property for muni_id, but there probably should be return genericCitation; }
From source file:mesclasses.model.Mot.java
public void setDateCloture(String date) { this.dateCloture.set(LocalDate.parse(date, Constants.DATE_FORMATTER)); }
From source file:dpfmanager.shell.interfaces.gui.component.report.ReportsController.java
private LocalDate parseFolderName(String folder) { try {/*from w w w. j a v a2 s. c o m*/ return LocalDate.parse(folder, DateTimeFormatter.ofPattern("yyyyMMdd")); } catch (Exception e) { return null; } }
From source file:br.com.ifpb.bdnc.projeto.geo.servlets.CadastraImagem.java
private Image mountImage(HttpServletRequest request) { Image image = new Image(); image.setCoord(new Coordenate()); boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { ServletFileUpload upload = new ServletFileUpload(); try {/*from w ww .j a va 2s . com*/ FileItemIterator itr = upload.getItemIterator(request); while (itr.hasNext()) { FileItemStream item = itr.next(); if (item.isFormField()) { InputStream in = item.openStream(); byte[] b = new byte[in.available()]; in.read(b); if (item.getFieldName().equals("description")) { image.setDescription(new String(b)); } else if (item.getFieldName().equals("authors")) { image.setAuthors(new String(b)); } else if (item.getFieldName().equals("end")) { image.setDate( LocalDate.parse(new String(b), DateTimeFormatter.ofPattern("yyyy-MM-dd"))); } else if (item.getFieldName().equals("latitude")) { image.getCoord().setLat(new String(b)); } else if (item.getFieldName().equals("longitude")) { image.getCoord().setLng(new String(b)); } else if (item.getFieldName().equals("heading")) { image.getCoord().setHeading(new String(b)); } else if (item.getFieldName().equals("pitch")) { image.getCoord().setPitch(new String(b)); } else if (item.getFieldName().equals("zoom")) { image.getCoord().setZoom(new String(b)); } } else { if (!item.getName().equals("")) { MultipartData md = new MultipartData(); String folder = "historicImages"; md.setFolder(folder); String path = request.getServletContext().getRealPath("/"); System.out.println(path); String nameToSave = "pubImage" + Calendar.getInstance().getTimeInMillis() + item.getName(); image.setImagePath(folder + "/" + nameToSave); md.saveImage(path, item, nameToSave); String imageMinPath = folder + "/" + "min" + nameToSave; RedimencionadorImagem.resize(path, folder + "/" + nameToSave, path + "/" + imageMinPath.toString(), IMAGE_MIN_WIDTH, IMAGE_MIM_HEIGHT); image.setMinImagePath(imageMinPath); } } } } catch (FileUploadException | IOException ex) { System.out.println("Erro ao manipular dados"); } } return image; }