Java Code Examples for java.time.LocalDate#MIN

The following examples show how to use java.time.LocalDate#MIN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKLocalDate.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() {
    TEST_2007_07_15 = LocalDate.of(2007, 7, 15);

    LocalDate max = LocalDate.MAX;
    LocalDate min = LocalDate.MIN;
    MAX_VALID_EPOCHDAYS = max.toEpochDay();
    MIN_VALID_EPOCHDAYS = min.toEpochDay();
    MAX_DATE = max;
    MIN_DATE = min;
    MAX_INSTANT = max.atStartOfDay(ZoneOffset.UTC).toInstant();
    MIN_INSTANT = min.atStartOfDay(ZoneOffset.UTC).toInstant();
}
 
Example 2
Source File: TCKLocalDate.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() {
    TEST_2007_07_15 = LocalDate.of(2007, 7, 15);

    LocalDate max = LocalDate.MAX;
    LocalDate min = LocalDate.MIN;
    MAX_VALID_EPOCHDAYS = max.toEpochDay();
    MIN_VALID_EPOCHDAYS = min.toEpochDay();
    MAX_DATE = max;
    MIN_DATE = min;
    MAX_INSTANT = max.atStartOfDay(ZoneOffset.UTC).toInstant();
    MIN_INSTANT = min.atStartOfDay(ZoneOffset.UTC).toInstant();
}
 
Example 3
Source File: TCKLocalDate.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() {
    TEST_2007_07_15 = LocalDate.of(2007, 7, 15);

    LocalDate max = LocalDate.MAX;
    LocalDate min = LocalDate.MIN;
    MAX_VALID_EPOCHDAYS = max.toEpochDay();
    MIN_VALID_EPOCHDAYS = min.toEpochDay();
    MAX_DATE = max;
    MIN_DATE = min;
    MAX_INSTANT = max.atStartOfDay(ZoneOffset.UTC).toInstant();
    MIN_INSTANT = min.atStartOfDay(ZoneOffset.UTC).toInstant();
}
 
Example 4
Source File: SparseLocalDateDoubleTimeSeries.java    From Strata with Apache License 2.0 5 votes vote down vote up
private static void validate(LocalDate[] dates, double[] values) {
  ArgChecker.isTrue(dates.length == values.length,
      "Arrays are of different sizes - dates: {}, values: {}", dates.length, values.length);
  LocalDate maxDate = LocalDate.MIN;
  for (LocalDate date : dates) {
    ArgChecker.isTrue(date.isAfter(maxDate),
        "Dates must be in ascending order but: {} is not after: {}", date, maxDate);
    maxDate = date;
  }
}
 
Example 5
Source File: TCKLocalDate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() {
    TEST_2007_07_15 = LocalDate.of(2007, 7, 15);

    LocalDate max = LocalDate.MAX;
    LocalDate min = LocalDate.MIN;
    MAX_VALID_EPOCHDAYS = max.toEpochDay();
    MIN_VALID_EPOCHDAYS = min.toEpochDay();
    MAX_DATE = max;
    MIN_DATE = min;
    MAX_INSTANT = max.atStartOfDay(ZoneOffset.UTC).toInstant();
    MIN_INSTANT = min.atStartOfDay(ZoneOffset.UTC).toInstant();
}
 
Example 6
Source File: ReChargeLabOpenCons.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private LocalDate getLocalDate(LabResult labResult){
	if (labResult.getObservationTime() != null) {
		return labResult.getObservationTime().toLocalDate();
	} else if (labResult.getDateTime() != null) {
		return labResult.getDateTime().toLocalDate();
	}
	LoggerFactory.getLogger(getClass())
		.warn("No local date for lab result [" + labResult.getId() + "]");
	return LocalDate.MIN;
}
 
Example 7
Source File: BinaryGenerator.java    From pgadba with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * parses a LocalDate to a byte array.
 *
 * @param input the LocalDate to convert
 * @return a byte array
 */
public static byte[] fromLocalDate(Object input) {
  if (input == null) {
    return new byte[]{};
  }

  if (input instanceof LocalDate) {
    LocalDate x = (LocalDate) input;
    if (x == LocalDate.MAX) {
      return "infinity".getBytes(StandardCharsets.UTF_8);
    } else if (x == LocalDate.MIN) {
      return "-infinity".getBytes(StandardCharsets.UTF_8);
    }

    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    try {
      baos.write(x.format(localDateFormatter).getBytes(StandardCharsets.UTF_8));

      if (x.getYear() < 0) {
        baos.write(" BC".getBytes(StandardCharsets.UTF_8));
      }

      return baos.toByteArray();
    } catch (IOException e) {
      throw new IllegalArgumentException("couldn't parse input to byte array", e);
    }
  }

  throw new RuntimeException(input.getClass().getName() + " can't be converted to byte[] to send as a LocalDate to server");
}
 
Example 8
Source File: TCKLocalDate.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() {
    TEST_2007_07_15 = LocalDate.of(2007, 7, 15);

    LocalDate max = LocalDate.MAX;
    LocalDate min = LocalDate.MIN;
    MAX_VALID_EPOCHDAYS = max.toEpochDay();
    MIN_VALID_EPOCHDAYS = min.toEpochDay();
    MAX_DATE = max;
    MIN_DATE = min;
    MAX_INSTANT = max.atStartOfDay(ZoneOffset.UTC).toInstant();
    MIN_INSTANT = min.atStartOfDay(ZoneOffset.UTC).toInstant();
}
 
Example 9
Source File: TCKLocalDate.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() {
    TEST_2007_07_15 = LocalDate.of(2007, 7, 15);

    LocalDate max = LocalDate.MAX;
    LocalDate min = LocalDate.MIN;
    MAX_VALID_EPOCHDAYS = max.toEpochDay();
    MIN_VALID_EPOCHDAYS = min.toEpochDay();
    MAX_DATE = max;
    MIN_DATE = min;
    MAX_INSTANT = max.atStartOfDay(ZoneOffset.UTC).toInstant();
    MIN_INSTANT = min.atStartOfDay(ZoneOffset.UTC).toInstant();
}
 
Example 10
Source File: TCKLocalDate.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@BeforeMethod
public void setUp() {
    TEST_2007_07_15 = LocalDate.of(2007, 7, 15);

    LocalDate max = LocalDate.MAX;
    LocalDate min = LocalDate.MIN;
    MAX_VALID_EPOCHDAYS = max.toEpochDay();
    MIN_VALID_EPOCHDAYS = min.toEpochDay();
    MAX_DATE = max;
    MIN_DATE = min;
    MAX_INSTANT = max.atStartOfDay(ZoneOffset.UTC).toInstant();
    MIN_INSTANT = min.atStartOfDay(ZoneOffset.UTC).toInstant();
}
 
Example 11
Source File: BinaryGenerator.java    From pgadba with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * parses a LocalDate to a byte array.
 *
 * @param input the LocalDate to convert
 * @return a byte array
 */
public static byte[] fromLocalDateArray(Object input) {
  if (input == null) {
    return new byte[]{};
  }

  if (input instanceof LocalDate[]) {
    LocalDate[] in = (LocalDate[]) input;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    try {
      baos.write('{');
      for (int i = 0; i < in.length; i++) {
        if (i != 0) {
          baos.write(',');
        }

        if (in[i] == null) {
          baos.write("NULL".getBytes(StandardCharsets.UTF_8));
          continue;
        }

        if (in[i] == LocalDate.MAX) {
          baos.write("infinity".getBytes(StandardCharsets.UTF_8));
          continue;
        } else if (in[i] == LocalDate.MIN) {
          baos.write("-infinity".getBytes(StandardCharsets.UTF_8));
          continue;
        }

        baos.write(in[i].format(localDateFormatter).getBytes(StandardCharsets.UTF_8));

        if (in[i].getYear() < 0) {
          baos.write(" BC".getBytes(StandardCharsets.UTF_8));
        }
      }
      baos.write('}');
    } catch (IOException e) {
      throw new IllegalArgumentException("couldn't parse input to byte array", e);
    }
    return baos.toByteArray();
  }

  throw new RuntimeException(input.getClass().getName() + " can't be converted to byte[] to send as a LocalDate[] to server");
}
 
Example 12
Source File: DefaultValueSlot.java    From Mutters with Apache License 2.0 4 votes vote down vote up
@Override
default LocalDate getDefaultValue()
{
  // "-999999999-01-01"
  return LocalDate.MIN;
}
 
Example 13
Source File: TCKLocalDate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_2007_07_15, LocalDate.MAX, LocalDate.MIN, };
    return Arrays.asList(array);
}
 
Example 14
Source File: TCKLocalDate.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_2007_07_15, LocalDate.MAX, LocalDate.MIN, };
    return Arrays.asList(array);
}
 
Example 15
Source File: TCKLocalDate.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_2007_07_15, LocalDate.MAX, LocalDate.MIN, };
    return Arrays.asList(array);
}
 
Example 16
Source File: TCKLocalDate.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_2007_07_15, LocalDate.MAX, LocalDate.MIN, };
    return Arrays.asList(array);
}
 
Example 17
Source File: TCKLocalDate.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected List<TemporalAccessor> samples() {
    TemporalAccessor[] array = {TEST_2007_07_15, LocalDate.MAX, LocalDate.MIN, };
    return Arrays.asList(array);
}
 
Example 18
Source File: QuoteTests.java    From morpheus-core with Apache License 2.0 4 votes vote down vote up
@Test()
public void testCrossSectionalReturns() throws Exception {
    LocalDate startDate = LocalDate.MIN;
    LocalDate endDate = LocalDate.MAX;
    final Index<LocalDate> rowKeys = Index.of(LocalDate.class, 100);
    final Index<String> tickers = Index.of("BLK", "CSCO", "SPY", "YHOO", "VNQI", "VGLT", "VCLT");
    final DataFrame<LocalDate,String> closePrices = DataFrame.ofDoubles(rowKeys, tickers);
    for (String ticker : tickers) {
        System.out.println("Loading data for ticker " + ticker);
        final DataFrame<LocalDate,String> quotes = TestDataFrames.getQuotes(ticker);
        quotes.tail(10).out().print();
        closePrices.rows().addAll(quotes.rows().keyArray());
        final LocalDate firstKey = quotes.rows().firstKey().get();
        final LocalDate lastKey = quotes.rows().lastKey().get();
        startDate = firstKey.isAfter(startDate) ? firstKey : startDate;
        endDate = lastKey.isBefore(endDate) ? lastKey : endDate;
        quotes.rows().forEach(row -> {
            final LocalDate date = row.key();
            final double price = row.getDouble("Adj Close");
            closePrices.data().setDouble(date, ticker, price);
        });
    }

    final Set<LocalDate> nanDates = new HashSet<>();
    closePrices.rows().forEach(row -> row.forEachValue(v -> {
        final double value = v.getDouble();
        if (Double.isNaN(value)) {
            final LocalDate rowKey = row.key();
            nanDates.add(rowKey);
            if (rowKey.getYear() == 2014) {
                System.out.println(rowKey);
            }
        }
    }));

    final DataFrame<LocalDate,String> selection = closePrices.rows().select(row -> !nanDates.contains(row.key()));
    final DataFrame<LocalDate,String> sorted = selection.rows().sort((row1, row2) -> row1.key().compareTo(row2.key()));
    final DataFrame<LocalDate,String> returns = sorted.calc().percentChanges();
    returns.rows().first().get().applyDoubles(v -> 0d);
    returns.head(10).out().print();
    returns.cols().stats().correlation().out().print();
}
 
Example 19
Source File: LocalDateRangeRandomizerTest.java    From easy-random with MIT License 4 votes vote down vote up
@BeforeEach
void setUp() {
    minDate = LocalDate.MIN;
    maxDate = LocalDate.MAX;
    randomizer = aNewLocalDateRangeRandomizer(minDate, maxDate);
}
 
Example 20
Source File: LocalDateRangeRandomizer.java    From easy-random with MIT License 4 votes vote down vote up
@Override
protected LocalDate getDefaultMinValue() {
    return LocalDate.MIN;
}