List of usage examples for org.joda.time LocalDate parse
@FromString public static LocalDate parse(String str)
From source file:eu.edisonproject.classification.prepare.model.Date.java
License:Apache License
public void extract() { /*Document doc = Jsoup.parse(this.getJp().getDescription()); Element link = doc.select("date").first(); String text = doc.body().text(); //from www .j a v a 2 s . co m System.out.println(text); */ if (this.getJp().getDescription().contains(" date") == true) { int start = this.getJp().getDescription().indexOf(" date"); try { date = LocalDate.parse(this.getJp().getDescription().substring(start, start + 50)); //System.out.println("F"+ date); } catch (Exception e) { //System.out.println("Exception date can't be parsed in LocalDate"); } } this.getJp().setDate(date); }
From source file:fi.vm.sade.osoitepalvelu.kooste.common.dtoconverter.AbstractDtoConverter.java
License:EUPL
@Override protected void registerConverters(TypeConversionContainer conversions) { super.registerConverters(conversions); conversions.add(String.class, LocalDate.class, new TypeConverterAdapter<String, LocalDate>() { public LocalDate convert(String obj) { // uses ISODateTimeFormat.localDateParser() that covers SQL date format return LocalDate.parse(obj); }/*from w w w. java 2s . c om*/ }).add(LocalDate.class, String.class, new TypeConverterAdapter<LocalDate, String>() { public String convert(LocalDate obj) { return obj.toString(); // ISO8601 format (yyyy-MM-dd) } }); }
From source file:fi.vm.sade.osoitepalvelu.kooste.scheduled.ScheduledOrganisaatioCacheTask.java
License:EUPL
/** * Does not purge fresh cache records but ensures that all organisaatios are cached. *///from w w w . ja v a 2 s . c om public void ensureOrganisaatioCacheFresh() { logger.info("BEGIN SCHEDULED ensureOrganisaatioCacheFresh."); showCacheState(); LocalDate cacheInvalidBefore = null; if (cacheValidFrom != null && cacheValidFrom.length() > 0) { cacheInvalidBefore = LocalDate.parse(cacheValidFrom); } // No CAS here (not needed for reading organisaatio service): final DefaultCamelRequestContext context = new DefaultCamelRequestContext( new ProviderOverriddenCasTicketCache(new CasDisabledCasTicketProvider())); if (cacheInvalidBefore != null && new DateTime().compareTo(cacheInvalidBefore.toDateTimeAtStartOfDay()) < 0) { context.setOverriddenTime(cacheInvalidBefore.toDateTimeAtStartOfDay()); } List<String> oids = retryOnCamelError(new Callable<List<String>>() { public List<String> call() { return organisaatioServiceRoute.findAllOrganisaatioOids(context); } }, MAX_TRIES, WAIT_BEFORE_RETRY_MILLIS); removeCachedDeletedOrganisaatios(oids); logger.info("Found {} organisaatios to ensure cache.", oids.size()); boolean infoUpdated = false; try { int i = 0; for (final String oid : oids) { ++i; // ...and renew the cache: long rc = context.getRequestCount(); retryOnCamelError(new Callable<OrganisaatioDetailsDto>() { public OrganisaatioDetailsDto call() { return organisaatioService.getdOrganisaatioByOid(oid, context); } }, MAX_TRIES, WAIT_BEFORE_RETRY_MILLIS); if (rc != context.getRequestCount()) { infoUpdated = true; logger.debug("Updated organisaatio {} (Total: {} / {})", new Object[] { oid, i, oids.size() }); } else if (i % LOGGIN_INTERVAL == 0) { logger.info("Organisaatio ensure data fresh task status: {} / {}", new Object[] { i, oids.size() }); } } } finally { if (infoUpdated) { logger.debug("UPDATING y-tunnus details..."); organisaatioService.updateOrganisaatioYtunnusDetails(context); logger.debug("DONE UPDATING y-tunnus details"); } } logger.info("END SCHEDULED ensureOrganisaatioCacheFresh."); }
From source file:fixtures.url.implementation.PathsImpl.java
License:Open Source License
/** * Get '2012-01-01' as date./*from w w w .j a va 2 s. c o m*/ * * @return the {@link ServiceResponse} object if successful. */ public Observable<ServiceResponse<Void>> dateValidWithServiceResponseAsync() { final LocalDate datePath = LocalDate.parse("2012-01-01"); return service.dateValid(datePath) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() { @Override public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) { try { ServiceResponse<Void> clientResponse = dateValidDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); }
From source file:fixtures.url.implementation.QueriesImpl.java
License:Open Source License
/** * Get '2012-01-01' as date.//from w w w. jav a2 s.c o m * * @return the {@link ServiceResponse} object if successful. */ public Observable<ServiceResponse<Void>> dateValidWithServiceResponseAsync() { final LocalDate dateQuery = LocalDate.parse("2012-01-01"); return service.dateValid(dateQuery) .flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() { @Override public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) { try { ServiceResponse<Void> clientResponse = dateValidDelegate(response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); } } }); }
From source file:fm.last.musicbrainz.data.model.PartialDate.java
License:Apache License
public LocalDate toLocalDate() { if (year == null) { return null; } return LocalDate.parse(toString()); }
From source file:griffon.plugins.jodatime.JodatimeExtension.java
License:Apache License
public static LocalDate toLocalDate(String string) { return LocalDate.parse(string); }
From source file:io.datakernel.aggregation_db.keytype.KeyTypeDate.java
License:Apache License
KeyTypeDate() {
this(LocalDate.parse("1970-01-01"));
}
From source file:io.datakernel.aggregation_db.keytype.KeyTypeDate.java
License:Apache License
@Override public Object fromString(String str) throws ParseException { try {// www. j a v a 2 s .c o m LocalDate date = LocalDate.parse(str); return Days.daysBetween(startDate, date).getDays(); } catch (IllegalArgumentException e) { throw new ParseException("Could not parse date string: '" + str + "'", e); } }
From source file:org.activiti.form.engine.impl.cmd.GetCompletedFormDefinitionCmd.java
License:Apache License
public void fillVariablesWithFormValues(Map<String, JsonNode> submittedFormFieldMap, List<FormField> allFields) { for (FormField field : allFields) { JsonNode fieldValueNode = submittedFormFieldMap.get(field.getId()); if (fieldValueNode == null || fieldValueNode.isNull()) { continue; }//from w w w .j av a2s. c o m String fieldType = field.getType(); String fieldValue = fieldValueNode.asText(); if (FormFieldTypes.DATE.equals(fieldType)) { try { if (StringUtils.isNotEmpty(fieldValue)) { LocalDate dateValue = LocalDate.parse(fieldValue); variables.put(field.getId(), dateValue.toString("d-M-yyyy")); } } catch (Exception e) { logger.error("Error parsing form date value for process instance " + processInstanceId + " and task " + taskId + " with value " + fieldValue, e); } } else { variables.put(field.getId(), fieldValue); } } }