List of usage examples for org.joda.time LocalDate parse
@FromString public static LocalDate parse(String str)
From source file:com.leonarduk.finance.utils.DateUtils.java
License:Open Source License
public static Date parseDate(final String fieldValue) throws ParseException { if (null == DateUtils.dates) { DateUtils.dates = Maps.newConcurrentMap(); }/*from w w w .ja v a 2 s. com*/ return (DateUtils.dates.computeIfAbsent(fieldValue, v -> LocalDate.parse(v).toDate())); }
From source file:com.stitchgalaxy.sg_manager_web.ProductController.java
@RequestMapping(value = UrlConstants.URL_PRODUCT_ADD, method = RequestMethod.POST) public String addProductCommand(Model model, @RequestParam(value = "name") String name, @RequestParam(value = "date") String sDate, @RequestParam(value = "price") BigDecimal price) throws DomainDataServiceException { CommandCreateProduct command = new CommandCreateProduct(); LocalDate date = LocalDate.parse(sDate); command.setDate(date);// w ww . ja v a 2s . c om command.setName(name); command.setPrice(price); domainDataService.createNewProduct(command); return "redirect:" + UrlConstants.URL_HOME; }
From source file:com.tomtom.speedtools.apivalidation.ApiValidator.java
License:Apache License
public void checkLocalDate(final boolean required, @Nonnull final String name, @Nullable final String value, @Nonnull final LocalDate minDate, @Nonnull final LocalDate maxDate) { checkNotNull(required, name, value); if (value != null) { try {//from w ww. ja va 2 s .co m final LocalDate localDate = LocalDate.parse(value); // Check range. if (localDate.isBefore(minDate) || localDate.isAfter(maxDate)) { errors.add(new ApiLocalDateOutOfRangeError(name, localDate, minDate, maxDate)); } } catch (final IllegalArgumentException ignored) { errors.add(new ApiLocalDateFormatError(name, value, FORMAT_DATE_ISO)); } } }
From source file:de.dreier.mytargets.features.settings.DatePreference.java
License:Open Source License
@Override protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { String value;// w w w .j a v a 2 s .c o m if (restoreValue) { if (defaultValue == null) { value = getPersistedString(LocalDate.now().toString()); } else { value = getPersistedString(defaultValue.toString()); } } else { value = defaultValue.toString(); } date = LocalDate.parse(value); }
From source file:de.dreier.mytargets.features.settings.SettingsManager.java
License:Open Source License
public static LocalDate getProfileBirthDay() { String date = preferences.getString(KEY_PROFILE_BIRTHDAY, ""); if (date.isEmpty()) { return null; }//from w w w .j av a2s .co m return LocalDate.parse(date); }
From source file:de.fraunhofer.iosb.ilt.sta.query.expression.constant.DateConstant.java
License:Open Source License
public DateConstant(String value) { if (value.lastIndexOf('-') <= 0) { // We do not want simple integers be interpreted as a year. throw new IllegalArgumentException("Not a date: " + value); }/*from w w w . jav a 2s . com*/ this.value = LocalDate.parse(value); }
From source file:divconq.struct.Struct.java
License:Open Source License
static public LocalDate objectToDate(Object o) { if (o == null) return null; if (o instanceof FieldStruct) return Struct.objectToDate(((FieldStruct) o).getValue()); if (o instanceof NullStruct) return null; if (o instanceof AnyStruct) o = ((AnyStruct) o).getValue();/*from www. j ava2 s .c om*/ else if (o instanceof DateStruct) o = ((DateStruct) o).getValue(); else if (o instanceof StringStruct) o = ((StringStruct) o).getValue(); if (o == null) return null; if (o instanceof LocalDate) return (LocalDate) o; if (o instanceof java.sql.Timestamp) return new LocalDate(((java.sql.Timestamp) o).getTime(), DateTimeZone.UTC); if (o instanceof CharSequence) { try { return LocalDate.parse(o.toString()); } catch (Exception x) { } } return null; }
From source file:eafit.cdei.asignacion.input.Ejemplo.java
/** * @param args the command line arguments *//*from w w w . jav a2 s. c o m*/ public static void main(String[] args) { LocalDate mondayDate = LocalDate.parse("2014-10-20"); String tmpDay = mondayDate.toString("EEEE"); DateTimeFormatter date = DateTimeFormat.forPattern("yyyy-mm-dd"); DateTimeFormatter time = DateTimeFormat.forPattern("hh:mm:ss"); String day = date.parseDateTime("2015-04-16").dayOfWeek().getAsText(); System.out.println(tmpDay + "/" + day); }
From source file:eafit.cdei.asignacion.vo.Teacher.java
public void addCourseAvaliability(List<TimeDayLocation> pt) { DateTimeFormatter fmt = DateTimeFormat.forPattern("YY-MM-DDH:mm:ss"); LocalDate mondayDate = LocalDate.parse("2014-10-20"); meetTimeIntervals = new ArrayList<>(); for (TimeDayLocation tdl : pt) { String key = tdl.getDow().dayOfWeek().getAsText() + tdl.getTimeStartString() + tdl.getTimeEndString(); if (!mapCoursesAvaliability.containsKey(key)) { getMapCoursesAvaliability().put(key, tdl); getListAvaliability().add(tdl); for (int x = 0; x <= 6; x++) { LocalDate tmpStartDate = mondayDate.plusDays(x); String tmpDay = tmpStartDate.toString("EEEE"); if (tmpStartDate.dayOfWeek().equals(tdl.getDow().dayOfWeek())) { DateTime tmpStartDateTime = DateTime.parse( tmpStartDate.toString("YY-MM-DD") + tdl.getTimeStart().toString("H:mm:ss"), fmt); DateTime tmpStopDateTime = DateTime.parse( tmpStartDate.toString("YY-MM-DD") + tdl.getTimeEnd().toString("H:mm:ss"), fmt); meetTimeIntervals.add(new Interval(tmpStartDateTime, tmpStopDateTime)); }/*from w w w. j ava2 s .c o m*/ } } } }
From source file:eafit.cdei.util.IntervalGenerator.java
public static List<Interval> getIntervals(List<String> days, Time startTime, Time stopTime) { DateTimeFormatter fmt = DateTimeFormat.forPattern("YY-MM-DDH:mm:ss"); List<Interval> tmpMeetTimeIntervals = new ArrayList<Interval>(); LocalDate mondayDate = LocalDate.parse("2014-10-20"); for (int x = 0; x <= 5; x++) { LocalDate tmpStartDate = mondayDate.plusDays(x); String tmpDay = tmpStartDate.toString("EEEE"); if (days.contains(tmpDay)) { DateTime tmpStartDateTime = DateTime.parse( tmpStartDate.toString("YY-MM-DD") + LocalTime.fromDateFields(startTime).toString("H:mm:ss"), fmt);// w ww.jav a 2 s . co m DateTime tmpStopDateTime = DateTime.parse( tmpStartDate.toString("YY-MM-DD") + LocalTime.fromDateFields(stopTime).toString("H:mm:ss"), fmt); tmpMeetTimeIntervals.add(new Interval(tmpStartDateTime, tmpStopDateTime)); } } return tmpMeetTimeIntervals; }