Seitenhistorie
...
Datum formatieren
Codeblock |
---|
import java.text.SimpleDateFormat; SimpleDateFormat formatdf = new SimpleDateFormat("dd.MM.yyyy"); sDateFormattedString s = formatdf.format(new Date()); |
liefert heutiges Datum als formatierten String.
Zahl formatieren
Codeblock |
---|
import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; DecimalFormat nf = new DecimalFormat("#,##0.0000"); nf.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.GERMAN)); String s = nf.format(new Double(1)); |
Führende Nullen ergänzen
Codeblock | ||
---|---|---|
| ||
int i = 9; sNumber = String.format("%04d", i); |
...
Überblick
Inhalte