List of usage examples for org.joda.time LocalDate toDate
@SuppressWarnings("deprecation") public Date toDate()
java.util.Date
. From source file:com.gst.portfolio.address.domain.Address.java
License:Apache License
private Address(final String street, final String addressLine1, final String addressLine2, final String addressLine3, final String townVillage, final String city, final String countyDistrict, final CodeValue stateProvince, final CodeValue country, final String postalCode, final BigDecimal latitude, final BigDecimal longitude, final String createdBy, final LocalDate createdOn, final String updatedBy, final LocalDate updatedOn) { this.street = street; this.addressLine1 = addressLine1; this.addressLine2 = addressLine2; this.addressLine3 = addressLine3; this.townVillage = townVillage; this.city = city; this.countyDistrict = countyDistrict; this.stateProvince = stateProvince; this.country = country; this.postalCode = postalCode; this.latitude = latitude; this.longitude = longitude; this.createdBy = createdBy; //this.createdOn = createdOn; this.updatedBy = updatedBy; //this.updatedOn = updatedOn; if (createdOn != null) { this.createdOn = createdOn.toDate(); }/*from ww w . java 2 s.c o m*/ if (updatedOn != null) { this.updatedOn = updatedOn.toDate(); } }
From source file:com.gst.portfolio.address.domain.Address.java
License:Apache License
public void setCreatedOn(LocalDate createdOn) { this.createdOn = createdOn.toDate(); }
From source file:com.gst.portfolio.address.domain.Address.java
License:Apache License
public void setUpdatedOn(LocalDate updatedOn) { this.updatedOn = updatedOn.toDate(); ; }
From source file:com.gst.portfolio.calendar.domain.Calendar.java
License:Apache License
public Calendar(final String title, final String description, final String location, final LocalDate startDate, final LocalDate endDate, final Integer duration, final Integer typeId, final boolean repeating, final String recurrence, final Integer remindById, final Integer firstReminder, final Integer secondReminder, final Date meetingtime) { final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) .resource(CALENDAR_RESOURCE_NAME); final CalendarType calendarType = CalendarType.fromInt(typeId); if (calendarType.isCollection() && !repeating) { baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()) .failWithCodeNoParameterAddedToErrorCode("must.repeat.for.collection.calendar"); if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }//from www . ja va 2 s .c om } this.title = StringUtils.defaultIfEmpty(title, null); this.description = StringUtils.defaultIfEmpty(description, null); this.location = StringUtils.defaultIfEmpty(location, null); if (null != startDate) { this.startDate = startDate.toDateTimeAtStartOfDay().toDate(); } else { this.startDate = null; } if (null != endDate) { this.endDate = endDate.toDateTimeAtStartOfDay().toDate(); } else { this.endDate = null; } this.duration = duration; this.typeId = typeId; this.repeating = repeating; this.recurrence = StringUtils.defaultIfEmpty(recurrence, null); this.remindById = remindById; this.firstReminder = firstReminder; this.secondReminder = secondReminder; this.meetingtime = meetingtime; }
From source file:com.gst.portfolio.calendar.domain.Calendar.java
License:Apache License
public Map<String, Object> updateStartDateAndDerivedFeilds(final LocalDate newMeetingStartDate) { final Map<String, Object> actualChanges = new LinkedHashMap<>(9); final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); if (newMeetingStartDate.isBefore(currentDate)) { final String defaultUserMessage = "New meeting effective from date cannot be in past"; throw new CalendarDateException("new.start.date.cannot.be.in.past", defaultUserMessage, newMeetingStartDate, getStartDateLocalDate()); } else if (isStartDateAfter(newMeetingStartDate) && isStartDateBeforeOrEqual(currentDate)) { // new meeting date should be on or after start date or current // date// www . j a v a2 s .c o m final String defaultUserMessage = "New meeting effective from date cannot be a date before existing meeting start date"; throw new CalendarDateException("new.start.date.before.existing.date", defaultUserMessage, newMeetingStartDate, getStartDateLocalDate()); } else { actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), newMeetingStartDate.toString()); this.startDate = newMeetingStartDate.toDate(); /* * If meeting start date is changed then there is possibilities of * recurring day may change, so derive the recurring day and update * it if it is changed. For weekly type is weekday and for monthly * type it is day of the month */ CalendarFrequencyType calendarFrequencyType = CalendarUtils.getFrequency(this.recurrence); Integer interval = CalendarUtils.getInterval(this.recurrence); Integer repeatsOnDay = null; /* * Repeats on day, need to derive based on the start date */ if (calendarFrequencyType.isWeekly()) { repeatsOnDay = newMeetingStartDate.getDayOfWeek(); } else if (calendarFrequencyType.isMonthly()) { repeatsOnDay = newMeetingStartDate.getDayOfMonth(); } // TODO cover other recurrence also this.recurrence = constructRecurrence(calendarFrequencyType, interval, repeatsOnDay, null); } return actualChanges; }
From source file:com.gst.portfolio.calendar.domain.Calendar.java
License:Apache License
@SuppressWarnings("null") public Map<String, Object> updateRepeatingCalendar(final LocalDate calendarStartDate, final CalendarFrequencyType frequencyType, final Integer interval, final Integer repeatsOnDay, final Integer repeatsOnNthDay) { final Map<String, Object> actualChanges = new LinkedHashMap<>(9); if (calendarStartDate != null & this.startDate != null) { if (!calendarStartDate.equals(this.getStartDateLocalDate())) { actualChanges.put("startDate", calendarStartDate); this.startDate = calendarStartDate.toDate(); }/*from w w w . ja va2 s. c o m*/ } final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, repeatsOnDay, repeatsOnNthDay); if (!StringUtils.isBlank(this.recurrence) && !newRecurrence.equalsIgnoreCase(this.recurrence)) { actualChanges.put("recurrence", newRecurrence); this.recurrence = newRecurrence; } return actualChanges; }
From source file:com.gst.portfolio.calendar.domain.Calendar.java
License:Apache License
public void updateStartAndEndDate(final LocalDate startDate, final LocalDate endDate) { final CalendarFrequencyType frequencyType = CalendarUtils.getFrequency(this.recurrence); final Integer interval = new Integer(CalendarUtils.getInterval(this.recurrence)); final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, startDate.getDayOfWeek(), null);/* ww w . j a v a 2 s . com*/ this.recurrence = newRecurrence; this.startDate = startDate.toDate(); this.endDate = endDate.toDate(); }
From source file:com.gst.portfolio.calendar.service.CalendarReadPlatformServiceImpl.java
License:Apache License
private CalendarData retrieveApplicableCalendarFromHistory(Long calendarId, LocalDate compareDate) { try {//from www . j a va2s . c o m final CalendarDataFromHistoryMapper rm = new CalendarDataFromHistoryMapper(); final String sql = rm.schema() + " where c.calendar_id = ? and date(?) between c.start_date and c.end_date limit 1"; return this.jdbcTemplate.queryForObject(sql, rm, new Object[] { calendarId, compareDate.toDate() }); } catch (final EmptyResultDataAccessException e) { return null; } }
From source file:com.gst.portfolio.calendar.service.CalendarUtils.java
License:Apache License
private static LocalDate getNextRecurringDate(final Recur recur, final LocalDate seedDate, final LocalDate startDate) { final DateTime periodStart = new DateTime(startDate.toDate()); final Date seed = convertToiCal4JCompatibleDate(seedDate); final Date nextRecDate = recur.getNextDate(seed, periodStart); return nextRecDate == null ? null : new LocalDate(nextRecDate); }
From source file:com.gst.portfolio.calendar.service.CalendarUtils.java
License:Apache License
private static Date convertToiCal4JCompatibleDate(final LocalDate inputDate) { // Date format in iCal4J is hard coded Date formattedDate = null;/* w ww . ja v a2 s . co m*/ final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); final String seedDateStr = df.format(inputDate.toDateTimeAtStartOfDay().toDate()); try { formattedDate = new Date(seedDateStr, "yyyy-MM-dd"); } catch (final ParseException e) { e.printStackTrace(); } return formattedDate; }