List of usage examples for java.time LocalDate getDayOfMonth
public int getDayOfMonth()
From source file:com.bdb.weather.display.summary.HighLowPanel.java
private void loadData(OHLCSeries series, SeriesInfo<T> info, List<SummaryRecord> records, int seriesIndex) { ObservableList<SummaryRecord> dataModel = FXCollections.observableList(records); dataTable.setItems(dataModel);/* w ww . j av a 2 s .c o m*/ for (SummaryRecord record : records) { T avg = info.getAvgValue(record); T min = info.getMinValue(record); T max = info.getMaxValue(record); LocalDate date = record.getDate(); // TODO: Figure out how to create a time period based on the specified interval RegularTimePeriod period = null; switch (interval) { case DAY_INTERVAL: period = new Hour(seriesIndex * 4, date.getDayOfMonth(), date.getMonth().getValue(), date.getYear()); break; case MONTH_INTERVAL: period = new Day(seriesIndex * 4 + 1, date.getMonth().getValue(), date.getYear()); break; case YEAR_INTERVAL: period = new Year(date.getYear()); break; default: period = null; break; } if (avg != null && min != null && max != null) { series.add(period, avg.get(), max.get(), min.get(), min.get()); } } }
From source file:org.knime.ext.textprocessing.nodes.transformation.stringstodocument.StringsToDocumentCellFactory.java
/** * {@inheritDoc}//w w w . ja v a2s . c om */ @Override public DataCell[] getCells(final DataRow row) { final DocumentBuilder docBuilder = new DocumentBuilder(m_tokenizerName); // Set title String title = m_config.getDocTitle(); if (m_config.getUseTitleColumn()) { if (m_config.getTitleStringIndex() >= 0) { final DataCell titleCell = row.getCell(m_config.getTitleStringIndex()); if (!titleCell.isMissing() && titleCell.getType().isCompatible(StringValue.class)) { title = ((StringValue) titleCell).getStringValue(); } else { title = ""; } docBuilder.addTitle(title); } } else { title = row.getKey().toString(); docBuilder.addTitle(title); } //Set fulltext if (m_config.getFulltextStringIndex() >= 0) { final DataCell textCell = row.getCell(m_config.getFulltextStringIndex()); String fulltext = ""; if (!textCell.isMissing() && textCell.getType().isCompatible(StringValue.class)) { fulltext = ((StringValue) textCell).getStringValue(); } docBuilder.addSection(fulltext, SectionAnnotation.UNKNOWN); } // Set authors if (m_config.getUseAuthorsColumn()) { if (m_config.getAuthorsStringIndex() >= 0) { final DataCell auhorsCell = row.getCell(m_config.getAuthorsStringIndex()); if (!auhorsCell.isMissing() && auhorsCell.getType().isCompatible(StringValue.class)) { final String authors = ((StringValue) auhorsCell).getStringValue(); final String[] authorsArr = authors.split(m_config.getAuthorsSplitChar()); for (String author : authorsArr) { String firstName = m_config.getAuthorFirstName(); String lastName = m_config.getAuthorLastName(); final String[] names = author.split(" "); if (names.length > 1) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < names.length - 1; i++) { sb.append(names[i]); sb.append(" "); } firstName = sb.toString(); lastName = names[names.length - 1]; } else if (names.length == 1) { lastName = names[0]; } docBuilder.addAuthor(new Author(firstName.trim(), lastName.trim())); } // If check box is set to use author names from column // if author first/last name is not specified and both first and last name in the node dialog // component are empty return an empty string. } else if (auhorsCell.isMissing() && (!m_config.getAuthorFirstName().isEmpty() || !m_config.getAuthorLastName().isEmpty())) { docBuilder.addAuthor(new Author(m_config.getAuthorFirstName(), m_config.getAuthorLastName())); } } } else if (!m_config.getAuthorFirstName().isEmpty() || !m_config.getAuthorLastName().isEmpty()) { // if no check box is set to use authors name from column, if both dialog components name are empty // return an empty string otherwise return "-" + the one specified. docBuilder.addAuthor(new Author(m_config.getAuthorFirstName(), m_config.getAuthorLastName())); } // set document source String docSource = m_config.getDocSource(); if (m_config.getUseSourceColumn()) { if (m_config.getSourceStringIndex() >= 0) { final DataCell sourceCell = row.getCell(m_config.getSourceStringIndex()); if (!sourceCell.isMissing() && sourceCell.getType().isCompatible(StringValue.class)) { docSource = ((StringValue) sourceCell).getStringValue(); } else { docSource = ""; } } } if (docSource.length() > 0) { docBuilder.addDocumentSource(new DocumentSource(docSource)); } // set document category String docCat = m_config.getDocCat(); if (m_config.getUseCatColumn()) { if (m_config.getCategoryStringIndex() >= 0) { final DataCell catCell = row.getCell(m_config.getCategoryStringIndex()); if (!catCell.isMissing() && catCell.getType().isCompatible(StringValue.class)) { docCat = ((StringValue) catCell).getStringValue(); } else { docCat = ""; } } } if (docCat.length() > 0) { docBuilder.addDocumentCategory(new DocumentCategory(docCat)); } // set document type docBuilder.setDocumentType(DocumentType.stringToDocumentType(m_config.getDocType())); // set publication date if (m_config.getUsePubDateColumn()) { if (m_config.getPubDateStringIndex() >= 0) { final DataCell pubDateCell = row.getCell(m_config.getPubDateStringIndex()); if (!pubDateCell.isMissing()) { // new LocalDate type if (pubDateCell.getType().isCompatible(LocalDateValue.class)) { LocalDate date = ((LocalDateValue) pubDateCell).getLocalDate(); setPublicationDate(docBuilder, date.getYear(), date.getMonthValue(), date.getDayOfMonth()); } else if (pubDateCell.getType().isCompatible(DateAndTimeValue.class)) { DateAndTimeValue dateTime = ((DateAndTimeValue) pubDateCell); setPublicationDate(docBuilder, dateTime.getYear(), dateTime.getMonth() + 1, dateTime.getDayOfMonth()); } else if (pubDateCell.getType().isCompatible(StringValue.class)) { extractAndSetPublicationDate(((StringValue) pubDateCell).getStringValue(), docBuilder); } } } } else { extractAndSetPublicationDate(m_config.getPublicationDate(), docBuilder); } DataCellCache dataCellCache = getDataCellCache(); return new DataCell[] { dataCellCache.getInstance(docBuilder.createDocument()) }; }
From source file:com.objy.se.ClassAccessor.java
public Object getCorrectValue(String strValue, LogicalType logicalType) { Object retValue = null;//from w w w . j a v a2 s .co m switch (logicalType) { case INTEGER: { long attrValue = 0; try { if (!strValue.equals("")) { attrValue = Long.parseLong(strValue); } } catch (NumberFormatException nfEx) { // System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey()); nfEx.printStackTrace(); throw nfEx; } retValue = Long.valueOf(attrValue); } break; case REAL: { double attrValue = 0; try { if (!strValue.equals("")) { attrValue = Double.parseDouble(strValue); } } catch (NumberFormatException nfEx) { // System.out.println("... entry: " + entry.getValue() + " for raw: " + entry.getKey()); nfEx.printStackTrace(); throw nfEx; } retValue = Double.valueOf(attrValue); } break; case STRING: retValue = strValue; break; case BOOLEAN: { if (strValue.equalsIgnoreCase("TRUE") || strValue.equals("1")) { retValue = Boolean.valueOf(true); } else if (strValue.equalsIgnoreCase("FALSE") || strValue.equals("0")) { retValue = Boolean.valueOf(false); } else { LOG.error("Expected Boolean value but got: {}", strValue); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case CHARACTER: { if (strValue.length() == 1) { retValue = Character.valueOf(strValue.charAt(0)); } else { /* not a char value... report that */ LOG.error("Expected Character value but got: {}", strValue); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case DATE: { try { LocalDate ldate = LocalDate.parse(strValue, dateFormatter); // System.out.println("... ... year: " + ldate.getYear() + " - month:" + ldate.getMonthValue()); retValue = new com.objy.db.Date(ldate.getYear(), ldate.getMonthValue(), ldate.getDayOfMonth()); } catch (DateTimeParseException ex) { LOG.error(ex.toString()); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case DATE_TIME: { try { // System.out.println(".... formatter: " + mapper.getDateTimeFormat()); LocalDateTime ldt = LocalDateTime.parse(strValue, dateTimeFormatter); // System.out.println("... ... year: " + ldt.getYear() + // " - month:" + ldt.getMonthValue() + " - day: " + // ldt.getDayOfMonth() + " - hour: " + ldt.getHour() + // " - min: " + ldt.getMinute() + " - sec: " + // ldt.getSecond() + " - nsec: " + ldt.getNano() ); //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL); retValue = new com.objy.db.DateTime(ldt.getYear(), ldt.getMonthValue(), ldt.getDayOfMonth(), ldt.getHour(), ldt.getMinute(), ldt.getSecond(), ldt.getNano()); } catch (DateTimeParseException ex) { LOG.error(ex.toString()); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } break; case TIME: { try { // System.out.println(".... formatter: " + mapper.getTimeFormat()); LocalDateTime ltime = LocalDateTime.parse(strValue, dateFormatter); // System.out.println("... ... hour: " + ltime.getHour() + // " - min: " + ltime.getMinute() + " - sec: " + // ltime.getSecond() + " - nsec: " + ltime.getNano() ); //retValue = new com.objy.db.DateTime(date.getTime(), TimeKind.LOCAL); retValue = new com.objy.db.Time(ltime.getHour(), ltime.getMinute(), ltime.getSecond(), ltime.getNano()); } catch (DateTimeParseException ex) { LOG.error(ex.toString()); throw new IllegalStateException("Possible invalid configuration... check mapper vs. schema" + "... or check records for invalid values"); } } default: { throw new UnsupportedOperationException("LogicalType: " + logicalType + " is not supported!!!"); } } return retValue; }
From source file:Pages.LandingPage.java
private String dateToString(LocalDate date) { String fixedDate;/*from w ww . ja v a2 s . c o m*/ fixedDate = String.valueOf(date.getYear()); fixedDate += "/" + String.valueOf(date.getDayOfMonth()); fixedDate += "/" + String.valueOf(date.getMonthValue()); return fixedDate; }
From source file:ui.Analyze.java
private void fillPermintaanTgl(LocalDate ld1, LocalDate ld2) { thnAkhir.setValue(ld1.getYear());// w ww . j a v a2s. c om blnAkhir.setValue(ld1.getMonthValue()); tglAkhir.setValue(ld1.getDayOfMonth()); thnAwal.setValue(ld2.getYear()); blnAwal.setValue(ld2.getMonthValue()); tglAwal.setValue(ld2.getDayOfMonth()); }
From source file:ui.Analyze.java
private void fillURTgl(LocalDate ld1, LocalDate ld2) { thnAkhirUR.setValue(ld1.getYear());// w w w. j a va 2s . c om blnAkhirUR.setValue(ld1.getMonthValue()); tglAkhirUR.setValue(ld1.getDayOfMonth()); thnAwalUR.setValue(ld2.getYear()); blnAwalUR.setValue(ld2.getMonthValue()); tglAwalUR.setValue(ld2.getDayOfMonth()); }
From source file:ui.Analyze.java
private void fillLabaTgl(LocalDate ld1, LocalDate ld2) { thnAkhirLaba.setValue(ld1.getYear()); blnAkhirLaba.setValue(ld1.getMonthValue()); tglAkhirLaba.setValue(ld1.getDayOfMonth()); thnAwalLaba.setValue(ld2.getYear()); blnAwalLaba.setValue(ld2.getMonthValue()); tglAwalLaba.setValue(ld2.getDayOfMonth()); }