![JAR search and dependency download from the Maven repository](/logo.png)
io.bretty.console.table.CurrencyNumberColumnFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of console-table-builder Show documentation
Show all versions of console-table-builder Show documentation
An extensible Java library to build stylish Excel-like tables, which can be converted into a single string with all table formats preserved.
The newest version!
/*
* Copyright (c) 2015 SUN XIMENG (Nathaniel). All rights reserved.
*/
package io.bretty.console.table;
class CurrencyNumberColumnFormatter extends NumberColumnFormatter {
private String symbol;
protected CurrencyNumberColumnFormatter(Alignment al, int width,
Precision p, String symbol) {
super(al, width, p);
this.symbol = symbol;
}
@Override
public String format(Number n) {
double value = n.doubleValue();
boolean negative = Double.compare(value, 0) < 0;
if (negative)
value = -value;
String abs = this.symbol;
if (this.symbol.length() > 1)
abs += " ";
abs += this.precision.format(value);
if (negative)
abs = "-" + abs;
return this.formatString(abs, this.width);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy