use of java.text.Format in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_parseObject_String.
//-----------------------------------------------------------------------
@Test
public void test_toFormat_parseObject_String() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
TemporalAccessor result = (TemporalAccessor) format.parseObject("ONE30");
assertEquals(result.isSupported(DAY_OF_MONTH), true);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
}
use of java.text.Format in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_Query_format.
//-----------------------------------------------------------------------
@Test
public void test_toFormat_Query_format() throws Exception {
Format format = BASIC_FORMATTER.toFormat();
String result = format.format(LocalDate.of(2008, 6, 30));
assertEquals(result, "ONE30");
}
use of java.text.Format in project jdk8u_jdk by JetBrains.
the class TCKDateTimeFormatter method test_toFormat_format_null.
@Test(expectedExceptions = NullPointerException.class)
public void test_toFormat_format_null() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
format.format(null);
}
use of java.text.Format in project jgnash by ccavanaugh.
the class InvestmentPerformanceSummary method toString.
@Override
public String toString() {
StringBuilder b = new StringBuilder();
Format percentageFormat = NumberFormat.getPercentInstance();
((NumberFormat) percentageFormat).setMinimumFractionDigits(2);
final String lineSep = System.lineSeparator();
for (SecurityPerformanceData data : performanceData.values()) {
b.append(data.getNode().getSymbol()).append(lineSep);
b.append("sharesHeld: ").append(data.getSharesHeld().toPlainString()).append(lineSep);
b.append("price: ").append(data.getPrice().toPlainString()).append(lineSep);
b.append("costBasisPerShare: ").append(data.getCostBasisPerShare().toPlainString()).append(lineSep);
b.append("costBasisShares: ").append(data.getCostBasisShares().toPlainString()).append(lineSep);
b.append("totalCostBasis: ").append(data.getTotalCostBasis().toPlainString()).append(lineSep);
b.append("heldCostBasis: ").append(data.getHeldCostBasis().toPlainString()).append(lineSep);
b.append("marketValue: ").append(data.getMarketValue().toPlainString()).append(lineSep);
b.append("unrealizedGains: ").append(data.getUnrealizedGains().toPlainString()).append(lineSep);
b.append("realizedGains: ").append(data.getRealizedGains().toPlainString()).append(lineSep);
b.append("totalGains: ").append(data.getTotalGains().toPlainString()).append(lineSep);
b.append("totalGainsPercentage: ").append(percentageFormat.format(data.getTotalGainsPercentage())).append(lineSep);
b.append("sharesSold: ").append(data.getSharesSold().toPlainString()).append(lineSep);
b.append("avgSalePrice: ").append(data.getAvgSalePrice().toPlainString()).append(lineSep);
b.append("percentPortfolio: ").append(percentageFormat.format(data.getPercentPortfolio())).append(lineSep);
b.append(lineSep);
}
return b.toString();
}
use of java.text.Format in project jgnash by ccavanaugh.
the class TableViewManager method getCalculatedColumnWidth.
/**
* Determines the preferred width of the column including contents.
*
* @param column {@code TableColumn} to measure content
* @return preferred width
*/
private double getCalculatedColumnWidth(final TableColumnBase<S, ?> column) {
double maxWidth = 0;
/* Collect all the unique cell items and remove null*/
final Set<Object> cellItems = new HashSet<>();
for (int i = 0; i < tableView.getItems().size(); i++) {
cellItems.add(column.getCellData(i));
}
cellItems.remove(null);
if (cellItems.size() > 0) {
// don't try if there is no data or the stream function will throw an error
final OptionalDouble max = cellItems.parallelStream().filter(Objects::nonNull).mapToDouble(o -> {
final Format format = columnFormatFactory.get().call(column);
return JavaFXUtils.getDisplayedTextWidth(format != null ? format.format(o) : o.toString(), column.getStyle());
}).max();
maxWidth = max.isPresent() ? max.getAsDouble() : 0;
}
//noinspection SuspiciousMethodCalls
maxWidth = Math.max(maxWidth, Math.max(column.getMinWidth(), minimumColumnWidthFactory.get().call(tableView.getColumns().indexOf(column))));
// header text width
maxWidth = Math.max(maxWidth, JavaFXUtils.getDisplayedTextWidth(column.getText(), column.getStyle()) * BOLD_MULTIPLIER);
return Math.ceil(maxWidth + COLUMN_PADDING);
}
Aggregations