List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:org.qi4j.sample.dcicargo.sample_a.bootstrap.sampledata.BaseData.java
License:Apache License
protected static Date day(int days) { return LocalDate.now().plusDays(days).toDate(); }
From source file:org.stocker.PingVerticle.java
License:Apache License
/** * use only for populating DB adhoc . NOT PROD CODE * @param updateRecordsRoute// w w w. j a v a 2s .com */ private void populateDB(UpdateRecordsRoute updateRecordsRoute) { Date date = LocalDate.now().toDate(); try { updateRecordsRoute.updateStocksForDate(date); } catch (NseDataObjParseException | StockDataNotFoundForGivenDateException | IOException e) { logger.warning(" failed with error - " + e.getMessage() + " for date - " + date.toString()); } }
From source file:org.vaadin.addons.tuningdatefield.TuningDateField.java
License:Apache License
protected CalendarItem[] buildDayItems() { LocalDate calendarFirstDay = getCalendarFirstDay(); LocalDate calendarLastDay = getCalendarLastDay(); LocalDate firstDayOfMonth = yearMonthDisplayed.toLocalDate(1); LocalDate lastDayOfMonth = yearMonthDisplayed.toLocalDate(1).dayOfMonth().withMaximumValue(); LocalDate today = LocalDate.now(); int numberOfDays = Days.daysBetween(calendarFirstDay, calendarLastDay).getDays() + 1; LocalDate date = calendarFirstDay; CalendarItem[] calendarItems = new CalendarItem[numberOfDays]; LocalDate currentValue = getLocalDate(); for (int i = 0; i < numberOfDays; i++, date = date.plusDays(1)) { calendarItems[i] = new CalendarItem(); calendarItems[i].setIndex(i);//from w w w . j a v a 2s . co m if (date.getMonthOfYear() == yearMonthDisplayed.getMonthOfYear()) { calendarItems[i].setRelativeDateIndex(date.getDayOfMonth()); } else { calendarItems[i].setRelativeDateIndex(-date.getDayOfMonth()); } String calendarItemContent = null; if (cellItemCustomizer != null) { calendarItemContent = cellItemCustomizer.renderDay(date, this); } // fallback to default value if (calendarItemContent == null) { calendarItemContent = Integer.toString(date.getDayOfMonth()); } calendarItems[i].setText(calendarItemContent); StringBuilder style = new StringBuilder(); if (date.equals(today)) { style.append("today "); } if (currentValue != null && date.equals(currentValue)) { style.append("selected "); } if (date.isBefore(firstDayOfMonth)) { style.append("previousmonth "); calendarItems[i].setEnabled(!isPreviousMonthDisabled()); } else if (date.isAfter(lastDayOfMonth)) { style.append("nextmonth "); calendarItems[i].setEnabled(!isNextMonthDisabled()); } else { style.append("currentmonth "); calendarItems[i].setEnabled(isDateEnabled(date)); } if (isWeekend(date)) { style.append("weekend "); } if (cellItemCustomizer != null) { String generatedStyle = cellItemCustomizer.getStyle(date, this); if (generatedStyle != null) { style.append(generatedStyle); style.append(" "); } String tooltip = cellItemCustomizer.getTooltip(date, this); if (tooltip != null) { calendarItems[i].setTooltip(tooltip); } } String computedStyle = style.toString(); if (!computedStyle.isEmpty()) { calendarItems[i].setStyle(computedStyle); } } return calendarItems; }
From source file:org.zalando.stups.fullstop.jobs.AccessKeyMetadataPredicates.java
License:Apache License
static Predicate<AccessKeyMetadata> withDaysOlderThan(final int days) { return t -> (t.getCreateDate().getTime() < LocalDate.now().minusDays(days).toDate().getTime()); }
From source file:pl.altkom.jpr.JodaTimeEx.java
License:Apache License
public static void main(String[] args) { LocalDate date = LocalDate.now(); System.out.println(date); }
From source file:pl.kodujdlapolski.na4lapy.service.user.UserServiceImpl.java
License:Apache License
@Override public int getPreferencesComplianceLevel(Animal animal) { if (mUserPreferences == null) { return 0; }// www. j av a2s . c o m int result = 0; if ((mUserPreferences.isTypeDog() && Species.DOG.equals(animal.getSpecies())) || (mUserPreferences.isTypeCat() && Species.CAT.equals(animal.getSpecies())) || (mUserPreferences.isTypeOther() && Species.OTHER.equals(animal.getSpecies()))) { ++result; } else { return 0; } if ((mUserPreferences.isGenderMan() && mUserPreferences.isGenderWoman() && Gender.UNKNOWN.equals(animal.getGender())) || (mUserPreferences.isGenderMan() && Gender.MALE.equals(animal.getGender())) || (mUserPreferences.isGenderWoman() && Gender.FEMALE.equals(animal.getGender()))) { ++result; } if (animal.getBirthDate() != null) { int age = Years.yearsBetween(animal.getBirthDate(), LocalDate.now()).getYears(); if (age >= mUserPreferences.getAgeMin() && age <= mUserPreferences.getAgeMax()) { ++result; } } if ((mUserPreferences.isSizeSmall() && mUserPreferences.isSizeMedium() && mUserPreferences.isSizeLarge() && Size.UNKNOWN.equals(animal.getSize())) || (mUserPreferences.isSizeSmall() && Size.SMALL.equals(animal.getSize())) || (mUserPreferences.isSizeMedium() && Size.MEDIUM.equals(animal.getSize())) || (mUserPreferences.isSizeLarge() && Size.LARGE.equals(animal.getSize()))) { ++result; } if ((mUserPreferences.isActivityLow() && mUserPreferences.isActivityHigh() && ActivityAnimal.UNKNOWN.equals(animal.getActivity())) || (mUserPreferences.isActivityLow() && ActivityAnimal.LOW.equals(animal.getActivity())) || (mUserPreferences.isActivityHigh() && ActivityAnimal.HIGH.equals(animal.getActivity()))) { ++result; } return result; }
From source file:pl.kodujdlapolski.na4lapy.ui.details.ContentDetailsView.java
License:Apache License
private String getShortDateTextFrom(@NonNull LocalDate date) { int age = Years.yearsBetween(date, LocalDate.now()).getYears(); int fromStringRes = R.plurals.years_from; if (age == 0) { age = Months.monthsBetween(date, LocalDate.now()).getMonths(); fromStringRes = R.plurals.months_from; }/*w ww.j a va 2 s . c o m*/ return ctx.getResources().getQuantityString(fromStringRes, age, age); }
From source file:pl.kodujdlapolski.na4lapy.ui.details.DetailsActivity.java
License:Apache License
public static String getAgeTextShort(Context context, @NonNull LocalDate date) { int age = Years.yearsBetween(date, LocalDate.now()).getYears(); int fromStringRes = R.plurals.years_short; if (age == 0) { age = Months.monthsBetween(date, LocalDate.now()).getMonths(); fromStringRes = R.plurals.months_short; }//from w w w. j a v a 2s. com return context.getResources().getQuantityString(fromStringRes, age, age); }
From source file:pt.ulisboa.tecnico.softeng.car.domain.Renting.java
public String cancel() { if (getKilometers() != -1) { throw new CarException(); }// ww w . jav a2 s . c o m setCancellationReference(getReference() + "CANCEL"); setCancellationDate(LocalDate.now()); this.getVehicle().getRentACar().getProcessor().submitRenting(this); return getCancellationReference(); }
From source file:reflex.value.ReflexDateValue.java
License:Open Source License
public ReflexDateValue(String yyyyMMdd, String calendar) { if (yyyyMMdd.isEmpty()) { date = LocalDate.now(); } else {/*w w w . j a va2 s . com*/ // Given a yyyyMMdd string, convert to a date try { date = new LocalDate(FORMATTER.parseDateTime(yyyyMMdd)); } catch (IllegalArgumentException e) { throw new ReflexException(-1, String.format("Bad date format %s - %s", yyyyMMdd, e.getMessage())); } catch (UnsupportedOperationException e) { throw new ReflexException(-1, String.format("Bad date format %s - %s", yyyyMMdd, e.getMessage())); } } this.calendarString = calendar; setupCalendarHandler(); }