@Override public LocalDate getLastUsedDate() { return new LocalDate(); } }
@SuppressWarnings("deprecation") public static LocalDate fromDayOfYear(int year, int dayOfYear) { // Use deprecated Date API because it compiles directly to Javascript builtin. Date jan1 = new LocalDate(year, 1, 1).atMidnightInMyTimezone(); jan1.setDate(dayOfYear); return new LocalDate(jan1); }
/** * @return true if the {@code other} interval overlaps this interval with at least one day. */ public boolean overlaps(LocalDateInterval other) { // Either the other interval finishes before this interval starts... // .. or it starts after this interval finishes return !(other.endDate.before(this.startDate) || other.startDate.after(this.endDate)); }
public static int encodeLocalDate(LocalDate value) { return value.getYear() << 16 | value.getMonthOfYear() << 8 | value.getDayOfMonth(); }
public static LocalDate getLastDateOfMonth(int year, int month) { return new LocalDate(year, month, getLastDayOfMonth(year, month)); }
public void setDate1(FieldValue value) { if(value != null) { this.date1 = ((LocalDate) value).atMidnightInMyTimezone(); } }
@Override @SuppressWarnings("deprecation") public Date parse(CharSequence text) throws ParseException { // Use a very lenient parser to allow for local input. // The result will always be formatted as a formatted string Date date; try { date = PARSER.parse(text.toString()).atMidnightInMyTimezone(); } catch (IllegalArgumentException e) { throw new ParseException(text.toString(), 0); } LocalDate localDate = new LocalDate(date); if(localDate.getYear() < 1000 || localDate.getYear() > 9999) { throw new ParseException(text.toString(), 0); } return date; }
static boolean isSnoozed(AccountStatus status, String snoozePrefix) { try { Storage storage = Storage.getLocalStorageIfSupported(); if(storage == null) { return false; } String accountSnooze = storage.getItem(snoozePrefix + status.getUserAccountId()); if(accountSnooze == null) { return false; } LocalDate snoozeDate = LocalDate.parse(accountSnooze); LocalDate today = new LocalDate(); if(today.before(snoozeDate)) { return true; } else { return false; } } catch (Exception e) { return false; } } }
@Override public void setValue(Cell cell, int row) { // Excel does not support date values prior to 1900, // so we have no choice but to render the value as text if the date occurs // prior to 1900. LocalDate localDate = renderer.render(row); if(localDate.getYear() < 1900) { cell.setCellValue(localDate.toString()); } else { cell.setCellValue(localDate.atMidnightInMyTimezone()); } } }
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())); }
@Override public void onSuccess(SqlTransaction tx, SqlResultSet results) { LocalDate today = new LocalDate(); LocalDate trialEndDate; if(!row.isNull("trialEndDate")) { trialEndDate = new LocalDate(row.getDate("trialEndDate")); } else { trialEndDate = new LocalDate(2050,1,1); db.setAccountEndDate(trialEndDate.toString()); db.setSuspended(trialEndDate.before(today)); } else { db.setBillingAccountName(row.get("baName")); db.setAccountEndDate(new LocalDate(row.getDate("baEndDate")).toString());
NumberBlock block = (NumberBlock) BlockFactory.get(quantityField); LocalDate startDate = new LocalDate(1980, 1, 1); LocalDate date = startDate; for (int j = 0; j < block.getBlockSize(); j++) { block.update(blockEntity, j, date); date = date.plusDays(1); assertThat(view.getString(0), equalTo(startDate.toString())); assertThat(view.getString(1), equalTo(startDate.plusDays(1).toString())); assertThat(view.getString(2), equalTo(startDate.plusDays(3).toString())); assertThat(view.getString(3), equalTo(startDate.plusDays(4).toString())); assertThat(view.getString(block.getBlockSize()), equalTo(startDate.plusDays(block.getBlockSize() + 1).toString())); assertThat(selected.getString(0), equalTo(startDate.plusDays(1).toString()));
@Test public void minDate() { LocalDate afterMinDate = new LocalDate(2017,01,01); assertTrue("Should be _after_ minimum date", afterMinDate.after(LocalDate.MIN_DATE)); LocalDate onMinDate = new LocalDate(1000,01,01); assertTrue("Should be _on_ minimum date", onMinDate.equals(LocalDate.MIN_DATE)); LocalDate beforeMinDate = new LocalDate(99,01,01); assertTrue("Should be _before_ minimum date", beforeMinDate.before(LocalDate.MIN_DATE)); }
@Override public Object toHrdProperty(LocalDate value) { // Use simple YYYY-MM-DD return value.toString(); }
@Override public ColumnView columnApply(int numRows, List<ColumnView> arguments) { ColumnView dateView = arguments.get(0); ColumnView daysView = arguments.get(1); String[] result = new String[dateView.numRows()]; for (int i = 0; i < dateView.numRows(); i++) { LocalDate date = LocalDate.parse(dateView.getString(i)); int days = (int)daysView.getDouble(i); result[i] = date.plusDays(days).toString(); } return new StringArrayColumnView(result); } }
@Override public LocalDate toFieldValue(Object hrdValue) { String stringValue = (String) hrdValue; return LocalDate.parse(stringValue); } };
@Override public Date render(int rowIndex) { assert view != null : "updateColumnSet() has not been called"; String text = view.getString(rowIndex); if(text == null) { return null; } return LocalDate.parse(text).atMidnightInMyTimezone(); }
public static LocalDateInterval month(int year, int month) { LocalDate start = new LocalDate(year, month, 1); LocalDate end = LocalDate.getLastDateOfMonth(year, month); return new LocalDateInterval(start, end); } }