List of usage examples for org.joda.time LocalDate LocalDate
public LocalDate(Object instant)
From source file:com.esofthead.mycollab.module.project.view.task.TaskEditFormFieldFactory.java
License:Open Source License
private void calculateDurationBaseOnStartAndEndDates() { DateTimeOptionField startDateField = (DateTimeOptionField) fieldGroup.getField(Task.Field.startdate.name()); DateTimeOptionField endDateField = (DateTimeOptionField) fieldGroup.getField(Task.Field.enddate.name()); TextField durationField = (TextField) fieldGroup.getField(Task.Field.duration.name()); Date startDate = null;/* w ww .jav a2s. co m*/ Date endDate = null; if (startDateField != null) { startDate = startDateField.getValue(); } if (endDateField != null) { endDate = endDateField.getValue(); } if (startDate != null && endDate != null && startDate.before(endDate) && durationField != null) { LocalDate startDateJoda = new LocalDate(startDate); LocalDate endDateJoda = new LocalDate(endDate); int durationInDays = BusinessDayTimeUtils.duration(startDateJoda, endDateJoda); durationField.setValue(durationInDays + " d"); } }
From source file:com.esofthead.mycollab.vaadin.web.ui.field.converter.LocalDateConverter.java
License:Open Source License
@Override public LocalDate convertToModel(Date value, Class<? extends LocalDate> targetType, Locale locale) throws ConversionException { return new LocalDate(value.getTime()); }
From source file:com.esofthead.mycollab.vaadin.web.ui.field.DateTimeOptionField.java
License:Open Source License
private Date getDateValue() { Date selectDate = popupDateField.getValue(); if (selectDate == null) { return null; }/*from w w w . j a va2s . c o m*/ DateTime jodaSelectDate = new DateTime(selectDate) .toDateTime(DateTimeZone.forTimeZone(AppContext.getUserTimeZone())); Date baseDate = new LocalDate(jodaSelectDate).toDate(); if (hideTimeOption) { return new LocalDateTime(baseDate).toDateTime(DateTimeZone.forTimeZone(AppContext.getUserTimeZone())) .toDate(); } else { Integer hour = (hourPickerComboBox.getValue() != null) ? Integer.parseInt((String) hourPickerComboBox.getValue()) : 0; Integer minus = (minutePickerComboBox.getValue() != null) ? Integer.parseInt((String) minutePickerComboBox.getValue()) : 0; String timeFormat = (timeFormatComboBox.getValue() != null) ? (String) timeFormatComboBox.getValue() : "AM"; long milliseconds = calculateMilliSeconds(hour, minus, timeFormat); DateTime jodaTime = new DateTime(baseDate).plus(new Duration(milliseconds)); return new LocalDateTime(jodaTime.getMillis()) .toDateTime(DateTimeZone.forTimeZone(AppContext.getUserTimeZone())).toDate(); } }
From source file:com.esofthead.mycollab.validator.constraints.DateComparisionValidator.java
License:Open Source License
@Override public boolean isValid(Object value, ConstraintValidatorContext context) { try {//from w ww . ja v a2 s.c om Date firstValue = (Date) PropertyUtils.getProperty(value, firstDateField); Date lastValue = (Date) PropertyUtils.getProperty(value, lastDateField); if (firstValue != null && lastValue != null) { LocalDate firstDate = new LocalDate(PropertyUtils.getProperty(value, firstDateField)); LocalDate lastDate = new LocalDate(PropertyUtils.getProperty(value, lastDateField)); return firstDate.compareTo(lastDate) <= 0; } return true; } catch (Exception ex) { return true; } }
From source file:com.excilys.sugadroid.beans.AppointmentBeanV5.java
License:Open Source License
public void setDateStart(LocalDateTime dateStart) { this.dateStart = new LocalDate(dateStart); timeStart = new LocalTime(dateStart); }
From source file:com.fct.api.utils.IdcardUtils.java
License:Open Source License
public static int getAgeByBirthday(Date birthday) { LocalDate birthdayDate = new LocalDate(birthday); LocalDate now = new LocalDate(); Years age = Years.yearsBetween(birthdayDate, now); return age.getYears(); }
From source file:com.fpt.mic.micweb.model.dto.form.CreateCompensationDto.java
@AssertTrue(message = "Khng th gi yu cu bi th?ng cho hp ng b hy qu th?i hn cp nht thng tin") private boolean isValidUpdateDueDate() { ContractDao contractDao = new ContractDao(); ContractEntity contractEntity = contractDao.read(contractCode); if (contractEntity != null && contractEntity.getStatus().equalsIgnoreCase(Constants.ContractStatus.CANCELLED)) { LocalDate cancelDate = new LocalDate(contractEntity.getCancelDate()); int durationFromCurrentToCancel = Days.daysBetween(cancelDate, new LocalDate()).getDays(); ConfigUtils configUtils = new ConfigUtils(); return durationFromCurrentToCancel <= configUtils.getUpdateContractDueDate(); } else {// w w w . j av a 2s . co m return true; } }
From source file:com.google.api.ads.adwords.awreporting.model.util.DateUtil.java
License:Open Source License
/** * Formats the date to the format: yyyyMMdd * * @param date the date as a {@code java.util.Date} * @return the {@code String} that represents the date as yyyyMMdd *//* w w w .j a v a 2 s . c om*/ public static String formatYearMonthDayNoDash(Date date) { return formatYearMonthDayNoDash(new LocalDate(date)); }
From source file:com.google.api.ads.adwords.awreporting.model.util.DateUtil.java
License:Open Source License
/** * Formats the date to the ISO format without the time zone information: yyyy-MM-dd * * @param date the date as a {@code java.util.Date} * @return the {@code String} that represents the date in ISO format */// w w w. j av a2s .c o m public static String formatYearMonthDay(Date date) { return formatYearMonthDay(new LocalDate(date)); }
From source file:com.google.api.ads.adwords.awreporting.model.util.DateUtil.java
License:Open Source License
/** * Formats the date to the ISO format without the time zone and day information: yyyy-MM * * @param date the date as a {@code java.util.Date} * @return the {@code String} that represents the date in ISO format *//*from w ww . j a v a 2s .c o m*/ public static String formatYearMonth(Date date) { return DateUtil.formatYearMonth(new LocalDate(date)); }