Java Code Examples for java.time.LocalDate#equals()
The following examples show how to use
java.time.LocalDate#equals() .
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: DateTimePane.java From phoebus with Eclipse Public License 1.0 | 6 votes |
@Override public void updateItem(final LocalDate item, final boolean empty) { super.updateItem(item, empty); if (empty) return; // Highlight the 'other' date and the dates in between if (item.equals(other.getValue())) setStyle("-fx-background-color: maroon;"); else if ((other.getValue().isBefore(item) && item.isBefore(self.getValue())) || (self.getValue().isBefore(item) && item.isBefore(other.getValue()))) setStyle("-fx-background-color: salmon;"); else setStyle(""); // Only enable dates up to today setDisable(LocalDate.now().isBefore(item)); }
Example 2
Source File: CSVSwaptionParser.java From finmath-lib with Apache License 2.0 | 5 votes |
/** * Extract an array of SwaptionDataLattice from the zip files. * The reference dates will be taken from the names of the files inside the archives. * The order of the files must be aligned inside the archives. * * @param atmFile The archive containing data on atm swpations. * @param otmFile The archive containing data on otm swaptions. * @param currency The currency, which should be parsed from the files. * @param index The index, which should be parsed from the files. * @param discountCurveName The name of the discount curve, which should be used by the swaptions. * * @return An array of lattices for each reference date. * * @throws IOException Thrown upon io error with File. */ public SwaptionDataLattice[] parseZIP(final File atmFile, final File otmFile, final String currency, final String index, final String discountCurveName) throws IOException { final ZipFile atmZip = new ZipFile(atmFile); final ZipFile otmZip = new ZipFile(otmFile); final List<SwaptionDataLattice> lattices = new ArrayList<>(); final Enumeration<? extends ZipEntry> atmEntries = atmZip.entries(); final Enumeration<? extends ZipEntry> otmEntries = otmZip.entries(); while(atmEntries.hasMoreElements() && otmEntries.hasMoreElements()) { final ZipEntry atmEntry = atmEntries.nextElement(); final ZipEntry otmEntry = otmEntries.nextElement(); final LocalDate referenceDate = LocalDate.parse(atmEntry.getName().replaceAll("\\D", ""), DateTimeFormatter.ofPattern("yyyyMMdd")); if(! referenceDate.equals(LocalDate.parse(otmEntry.getName().replaceAll("\\D", ""), DateTimeFormatter.ofPattern("yyyyMMdd")))) { atmZip.close(); otmZip.close(); throw new IllegalArgumentException("Files in zip archive not aligned for reference date."); } // TODO Add logging in case stream fails. try(InputStream atmStream = atmZip.getInputStream(atmEntry)) { try(InputStream otmStream = otmZip.getInputStream(otmEntry)) { lattices.add(parseStreams(atmStream, otmStream, referenceDate, currency, index, discountCurveName)); } } } atmZip.close(); otmZip.close(); return lattices.toArray(new SwaptionDataLattice[0]); }
Example 3
Source File: TCKLocalDate.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDate expected = LocalDate.now(Clock.system(zone)); LocalDate test = LocalDate.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = LocalDate.now(Clock.system(zone)); test = LocalDate.now(zone); } assertEquals(test, expected); }
Example 4
Source File: TCKLocalDate.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDate expected = LocalDate.now(Clock.system(zone)); LocalDate test = LocalDate.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = LocalDate.now(Clock.system(zone)); test = LocalDate.now(zone); } assertEquals(test, expected); }
Example 5
Source File: DiscountIborIndexRates.java From Strata with Apache License 2.0 | 5 votes |
@Override public PointSensitivityBuilder ratePointSensitivity(IborIndexObservation observation) { LocalDate fixingDate = observation.getFixingDate(); LocalDate valuationDate = getValuationDate(); if (fixingDate.isBefore(valuationDate) || (fixingDate.equals(valuationDate) && fixings.get(fixingDate).isPresent())) { return PointSensitivityBuilder.none(); } return IborRateSensitivity.of(observation, 1d); }
Example 6
Source File: TCKLocalDate.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDate expected = LocalDate.now(Clock.system(zone)); LocalDate test = LocalDate.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = LocalDate.now(Clock.system(zone)); test = LocalDate.now(zone); } assertEquals(test, expected); }
Example 7
Source File: TCKLocalDate.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now() { LocalDate expected = LocalDate.now(Clock.systemDefaultZone()); LocalDate test = LocalDate.now(); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = LocalDate.now(Clock.systemDefaultZone()); test = LocalDate.now(); } assertEquals(test, expected); }
Example 8
Source File: BattleLogController.java From logbook-kai with MIT License | 5 votes |
@FXML void initialize() { LocalDate date = LocalDate.now(); Callback<DatePicker, DateCell> callback = d -> new DateCell() { @Override public void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); this.getStyleClass().remove("selected"); this.getStyleClass().remove("contains"); LocalDate from = UnitDialog.this.from.getValue(); LocalDate to = UnitDialog.this.to.getValue(); if (from != null && to != null) { if (item.equals(from) || item.equals(to)) { this.getStyleClass().add("selected"); } else if ((from.compareTo(to) < 0 && item.compareTo(from) > 0 && item.compareTo(to) < 0) || (from.compareTo(to) > 0 && item.compareTo(from) < 0 && item.compareTo(to) > 0)) { this.getStyleClass().add("contains"); } } } }; this.to.setValue(date); this.to.setDayCellFactory(callback); this.from.setValue(date.minusWeeks(2)); this.from.setDayCellFactory(callback); }
Example 9
Source File: TCKLocalDate.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void now() { LocalDate expected = LocalDate.now(Clock.systemDefaultZone()); LocalDate test = LocalDate.now(); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = LocalDate.now(Clock.systemDefaultZone()); test = LocalDate.now(); } assertEquals(test, expected); }
Example 10
Source File: TCKLocalDate.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void now_ZoneId() { ZoneId zone = ZoneId.of("UTC+01:02:03"); LocalDate expected = LocalDate.now(Clock.system(zone)); LocalDate test = LocalDate.now(zone); for (int i = 0; i < 100; i++) { if (expected.equals(test)) { return; } expected = LocalDate.now(Clock.system(zone)); test = LocalDate.now(zone); } assertEquals(test, expected); }
Example 11
Source File: ThaiBuddhistDate.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private ThaiBuddhistDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new ThaiBuddhistDate(newDate)); }
Example 12
Source File: CSVSwaptionParser.java From finmath-lib with Apache License 2.0 | 4 votes |
/** * Extract an array of SwaptionDataLattice from the zip files. * The data in the zip file will be converted to the given quoting convention before storing. * The reference dates will be taken from the names of the files inside the archives. * The order of the files must be aligned inside the archives. * Only the data sets for which a model with matching reference date is provided will be evaluated. * * @param atmFile The archive containing data on atm swpations. * @param otmFile The archive containing data on otm swaptions. * @param currency The currency, which should be parsed from the files. * @param index The index, which should be parsed from the files. * @param discountCurveName The name of the discount curve, which should be used by the swaptions. * @param convention The quoting convention to store the data in. * @param displacement The displacement to use, if storing in convention VOLATILITYLOGNORMAL * @param models The models for context to use for each data set top convert to convention. * * @return An array of lattices for each reference date. * * @throws IOException Thrown upon io error with File. */ public SwaptionDataLattice[] parseZIPToConvention(final File atmFile, final File otmFile, final String currency, final String index, final String discountCurveName, final QuotingConvention convention, final double displacement, final AnalyticModel... models) throws IOException { //Convert array of model to map for lookup. final Map<LocalDate, AnalyticModel> modelMap = new HashMap<>(); for(final AnalyticModel model : models) { if(((AnalyticModelFromCurvesAndVols) model).getReferenceDate()==null) { throw new IllegalArgumentException("No reference date assigned to " + model.toString()); } modelMap.put(((AnalyticModelFromCurvesAndVols) model).getReferenceDate(), model); } final ZipFile atmZip = new ZipFile(atmFile); final ZipFile otmZip = new ZipFile(otmFile); final List<SwaptionDataLattice> lattices = new ArrayList<>(); final Enumeration<? extends ZipEntry> atmEntries = atmZip.entries(); final Enumeration<? extends ZipEntry> otmEntries = otmZip.entries(); while(atmEntries.hasMoreElements() && otmEntries.hasMoreElements()) { final ZipEntry atmEntry = atmEntries.nextElement(); final ZipEntry otmEntry = otmEntries.nextElement(); final LocalDate referenceDate = LocalDate.parse(atmEntry.getName().replaceAll("\\D", ""), DateTimeFormatter.ofPattern("yyyyMMdd")); if(! referenceDate.equals(LocalDate.parse(otmEntry.getName().replaceAll("\\D", ""), DateTimeFormatter.ofPattern("yyyyMMdd")))) { atmZip.close(); otmZip.close(); throw new IllegalArgumentException("Files in zip archive not aligned for reference date."); } //check if there is a model for these entries if(! modelMap.containsKey(referenceDate)) { continue; } lattices.add(parseStreamsToConvention(atmZip, atmEntry, otmZip, otmEntry, referenceDate, currency, index, discountCurveName, convention, displacement, modelMap.get(referenceDate))); } atmZip.close(); otmZip.close(); return lattices.toArray(new SwaptionDataLattice[0]); }
Example 13
Source File: JapaneseDate.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private JapaneseDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new JapaneseDate(newDate)); }
Example 14
Source File: ThaiBuddhistDate.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private ThaiBuddhistDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new ThaiBuddhistDate(newDate)); }
Example 15
Source File: MinguoDate.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private MinguoDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new MinguoDate(newDate)); }
Example 16
Source File: MinguoDate.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private MinguoDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new MinguoDate(newDate)); }
Example 17
Source File: ThaiBuddhistDate.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private ThaiBuddhistDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new ThaiBuddhistDate(newDate)); }
Example 18
Source File: MinguoDate.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private MinguoDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new MinguoDate(newDate)); }
Example 19
Source File: ThaiBuddhistDate.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private ThaiBuddhistDate with(LocalDate newDate) { return (newDate.equals(isoDate) ? this : new ThaiBuddhistDate(newDate)); }
Example 20
Source File: FxResetNotionalExchange.java From Strata with Apache License 2.0 | 4 votes |
@Override public FxResetNotionalExchange adjustPaymentDate(TemporalAdjuster adjuster) { LocalDate adjusted = paymentDate.with(adjuster); return adjusted.equals(paymentDate) ? this : new FxResetNotionalExchange(notionalAmount, adjusted, observation); }