下面列出了org.joda.time.LocalDate#plusDays ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@RequestMapping("/tx/cnt_static")
public ResponseVo<Map<String, Long>> transactionStatic() {
Date from = LocalDate.now().plusDays(-15).toDate();
Date to = LocalDate.now().toDate();
List<DayCount> dayCounts = ethService.countTransactionByTimestamp(from, to);
Map<String, Long> dayCountMap = dayCounts.stream()
.collect(Collectors.toMap(DayCount::getDay, DayCount::getCount));
LocalDate fromLocalDate = LocalDate.fromDateFields(from);
LocalDate toLocalDate = LocalDate.fromDateFields(to);
while (fromLocalDate.isBefore(toLocalDate)) {
dayCountMap.putIfAbsent(DateUtils.toDay(fromLocalDate.toDate()), 0L);
fromLocalDate = fromLocalDate.plusDays(1);
}
ResponseVo<Map<String, Long>> result = new ResponseVo<>();
result.setData(new TreeMap<>(dayCountMap));
return result;
}
/**
* 周视图的数据
*
* @param localDate
* @return
*/
public static List<LocalDate> getWeekCalendar(LocalDate localDate, int type) {
List<LocalDate> dateList = new ArrayList<>();
if (type == Attrs.MONDAY) {
localDate = getMonFirstDayOfWeek(localDate);
} else {
localDate = getSunFirstDayOfWeek(localDate);
}
for (int i = 0; i < 7; i++) {
LocalDate date = localDate.plusDays(i);
dateList.add(date);
}
return dateList;
}
private int getSyncedDays() {
LocalDate date = LocalDate.now().plusDays(1);
int i = 0;
while (i < 45) {
String prefix = date.toString("yyyy-MM-dd") + "-";
String[] times = {this.times.get(prefix + 0), this.times.get(prefix + 1), this.times.get(prefix + 2), this.times.get(prefix + 3),
this.times.get(prefix + 4), this.times.get(prefix + 5)};
for (String time : times) {
if (time == null || time.contains("00:00"))
return i;
}
i++;
date = date.plusDays(1);
}
return i;
}
@NonNull
public LocalDateTime getTime(@NonNull LocalDate date, int time) {
while (time < 0) {
date = date.minusDays(1);
time += Vakit.LENGTH;
}
while (time >= Vakit.LENGTH) {
date = date.plusDays(1);
time -= Vakit.LENGTH;
}
LocalDateTime dt = parseTime(date, getStrTime(date, Vakit.getByIndex(time))).plusMinutes(getMinuteAdj()[time]);
int h = dt.getHourOfDay();
if ((time >= Vakit.DHUHR.ordinal()) && (h < 5)) {
dt = dt.plusDays(1);
}
return dt;
}
private int getSyncedDays() {
LocalDate date = LocalDate.now().plusDays(1);
int i = 0;
while (i < 45) {
String prefix = date.toString("yyyy-MM-dd") + "-";
String[] times = {this.times.get(prefix + 0), this.times.get(prefix + 1), this.times.get(prefix + 2), this.times.get(prefix + 3),
this.times.get(prefix + 4), this.times.get(prefix + 5)};
for (String time : times) {
if (time == null || time.contains("00:00"))
return i;
}
i++;
date = date.plusDays(1);
}
return i;
}
@NonNull
public LocalDate getFirstSyncedDay() {
LocalDate date = LocalDate.now();
int i = 0;
while (true) {
String prefix = date.toString("yyyy-MM-dd") + "-";
String[] times = {this.times.get(prefix + 0), this.times.get(prefix + 1), this.times.get(prefix + 2), this.times.get(prefix + 3),
this.times.get(prefix + 4), this.times.get(prefix + 5)};
for (String time : times) {
if (time == null || time.contains("00:00") || i > this.times.size())
return date.plusDays(1);
}
i++;
date = date.minusDays(1);
}
}
@NonNull
public LocalDateTime getTime(@NonNull LocalDate date, int time) {
while (time < 0) {
date = date.minusDays(1);
time += Vakit.LENGTH;
}
while (time >= Vakit.LENGTH) {
date = date.plusDays(1);
time -= Vakit.LENGTH;
}
LocalDateTime dt = parseTime(date, getStrTime(date, Vakit.getByIndex(time))).plusMinutes(getMinuteAdj()[time]);
int h = dt.getHourOfDay();
if ((time >= Vakit.DHUHR.ordinal()) && (h < 5)) {
dt = dt.plusDays(1);
}
return dt;
}
public void testIsWorkingDay() {
LocalDate date = new LocalDate("2006-08-01");
Assert.assertTrue("Calendar.TUESDAY", ww.isWorkingDay(date));
date = date.plusDays(1);
Assert.assertTrue("Calendar.WEDNESDAY", ww.isWorkingDay(date));
date = date.plusDays(1);
Assert.assertTrue("Calendar.THURSDAY", ww.isWorkingDay(date));
date = date.plusDays(1);
Assert.assertTrue("Calendar.FRIDAY", ww.isWorkingDay(date));
date = date.plusDays(1);
Assert.assertFalse("Calendar.SATURDAY", ww.isWorkingDay(date));
date = date.plusDays(1);
Assert.assertFalse("Calendar.SUNDAY", ww.isWorkingDay(date));
date = date.plusDays(1);
Assert.assertTrue("Calendar.MONDAY", ww.isWorkingDay(date));
}
public void produceEmptyTurnoversForPropertyAndPeriod(final LocalDate startDate, final LocalDate endDate, final Property property) {
LocalDate date = startDate;
while (!date.isAfter(endDate)){
produceEmptyTurnoversFor(date, property);
date = date.plusDays(1);
}
}
public LocalDate adjustDate(final LocalDate startDate, final int increment, final NonWorkingDayChecker<LocalDate> checker) {
LocalDate date = startDate;
while (checker.isNonWorkingDay(date)) {
date = date.plusDays(increment);
}
return date;
}
@Action()
public Occupancy $$(final LocalDate startDate, final LocalDate endDate) {
if (!endDate.isBefore(startDate)){
final List<TurnoverReportingConfig> configs = turnoverReportingConfigRepository.findByOccupancy(occupancy);
LocalDate date = startDate;
while (!date.isAfter(endDate)){
for (TurnoverReportingConfig config : configs){
config.produceEmptyTurnover(date);
}
date = date.plusDays(1);
}
}
return occupancy;
}
@Override
protected ArrayList<DateHolder> generatePeriod() {
ArrayList<DateHolder> dates = new ArrayList<DateHolder>();
checkDate = new LocalDate(cPeriod);
int counter = 0;
int quantity = checkDate.dayOfYear().getMaximumValue();
while ((openFuturePeriods > 0 || currentDate.isAfter(checkDate)) && counter < quantity) {
String date = checkDate.toString(DATE_FORMAT);
String dName = checkDate.dayOfMonth().getAsString();
String mName = checkDate.monthOfYear().getAsText();
String yName = checkDate.year().getAsString();
String label = String.format(DATE_LABEL_FORMAT, dName, mName, yName);
if (checkDate.isBefore(maxDate) && isInInputPeriods(date)) {
DateHolder dateHolder = new DateHolder(date, checkDate.toString(), label);
dates.add(dateHolder);
}
counter++;
checkDate = checkDate.plusDays(1);
}
Collections.reverse(dates);
return dates;
}
@Test
public void verify_works() throws Exception {
// given
Organisation organisation = new Organisation();
organisation.clockService = mockClockService;
organisation.organisationPreviousNameRepository = mockOrganisationPreviousNameRepository;
final String looked_up_name = "Looked Up Name";
final String chamberOfCommerceCode = "123456789";
final LocalDate previousNameEndDate = new LocalDate(2017, 01,01);
OrganisationNameNumberViewModel vm = new OrganisationNameNumberViewModel(looked_up_name, chamberOfCommerceCode, previousNameEndDate.plusDays(1));
// expect
context.checking(new Expectations(){{
oneOf(mockOrganisationPreviousNameRepository).newOrganisationPreviousName(null, previousNameEndDate);
}});
// when
organisation.verify(vm);
// then
assertThat(organisation.getName()).isEqualTo(looked_up_name);
assertThat(organisation.getChamberOfCommerceCode()).isEqualTo(chamberOfCommerceCode);
assertThat(organisation.isVerified()).isTrue();
}
OrderMenu.OrderFinder filterOrFindByOrderDate(final LocalDate orderDate) {
if (orderDate == null)
return this;
LocalDate orderDateStart = orderDate.minusDays(5);
LocalDate orderDateEnd = orderDate.plusDays(5);
if (!this.result.isEmpty()) {
filterByOrderDate(orderDateStart, orderDateEnd);
} else {
createResultForOrderDate(orderDateStart, orderDateEnd);
}
return this;
}
public DayIterator(int openFPs, String[] dataInputPeriods) {
super(dataInputPeriods);
openFuturePeriods = openFPs;
cPeriod = new LocalDate(currentDate.getYear(), JAN, 1);
checkDate = new LocalDate(cPeriod);
maxDate = new LocalDate(currentDate.getYear(), currentDate.getMonthOfYear(), currentDate.getDayOfMonth());
for (int i = 0; i <= openFuturePeriods-1; i++) {
maxDate = maxDate.plusDays(1);
}
}
@Override
protected LocalDate getMaxDateCanEdit() {
LocalDate periodDate = LocalDate.parse(period,
DateTimeFormat.forPattern(DATE_FORMAT));
periodDate = periodDate.withMonthOfYear(monthOfYear());
periodDate = periodDate.plusMonths(plusMonths());
return periodDate.plusDays(expiryDays - 2);
}
@Override
protected LocalDate getMaxDateCanEdit() {
LocalDate periodDate = LocalDate.parse(period, DateTimeFormat.forPattern(getDateFormat()));
periodDate = periodDate.withDayOfWeek(weekStarts());
periodDate = periodDate.plusDays(6);
return periodDate.plusDays(expiryDays - 1);
}
public LocalDate adjustDate(LocalDate startDate, int increment, NonWorkingDayChecker<LocalDate> checker) {
LocalDate date = startDate;
while (checker.isNonWorkingDay(date)) {
if (increment < 0) {
// act as a Backward calendar
date = date.minusDays(1);
} else {
// move forward by a day!
date = date.plusDays(1);
}
}
return date;
}
@Override
protected LocalDate getMaxDateCanEdit() {
LocalDate periodDate = LocalDate.parse(period, DateTimeFormat.forPattern(getDateFormat()));
periodDate = periodDate.plusMonths(plusMonths());
return periodDate.plusDays(expiryDays - 2);
}
private static DateTime getStartDayOfNextMonthBiWeek(DateTime date){
LocalDate localDate = new LocalDate(getStartDayOfFirstBiWeek(date));
localDate = localDate.plusDays(28);
return localDate.toDateTimeAtStartOfDay();
}