@Override protected int apply(LocalDate date) { return date.getMonthOfYear(); }
@Override protected int apply(LocalDate date) { return fromMonth(date.getMonthOfYear()); }
@Override public PeriodValue containingDate(LocalDate localDate) { return new Month(localDate.getYear(), localDate.getMonthOfYear()); } }
public static int encodeLocalDate(LocalDate value) { return value.getYear() << 16 | value.getMonthOfYear() << 8 | value.getDayOfMonth(); }
@VisibleForTesting static double compute(LocalDate startDate, LocalDate endDate) { int y1 = startDate.getYear(); int y2 = endDate.getYear(); int m1 = startDate.getMonthOfYear(); int m2 = endDate.getMonthOfYear(); int d1 = startDate.getDayOfMonth(); int d2 = endDate.getDayOfMonth(); // If (Date1 is the last day of February) and (Date2 is the last day of February), // then change D2 to 30. if(lastDayOfFebruary(m1, d1) && lastDayOfFebruary(m2, d2)) { d2 = 30; } if (lastDayOfFebruary(m1, d1)) { d1 = 30; } if(d2 == 31 && (d1 == 30 || d1 == 31)) { d2 = 30; } if(d1 == 31) { d1 = 30; } return Math.abs((360d * (y2-y1) + 30d * (m2-m1) + (d2-d1)) / 360d); }
private static FormulaNode dateValue(FilterConfig filter) { // GXT serializes the date value as unix time value in milliseconds long time = Long.parseLong(filter.getValue()); Date date = new Date(time); LocalDate localDate = new LocalDate(date); return new FunctionCallNode(DateFunction.INSTANCE, new ConstantNode(localDate.getYear()), new ConstantNode(localDate.getMonthOfYear()), new ConstantNode(localDate.getDayOfMonth())); }