Seitenhistorie
Formatierungen in Java
Typische Formatierungsanforderungen, die man in Regeln immer wieder hat und jedes Mal mühsam nachschlagen muss.
Datum formatieren
Codeblock |
---|
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy"); sDateFormatted = format.format(new Date()); |
liefert heutiges Datum als formatierten String.
Führende Nullen ergänzen
Codeblock | ||
---|---|---|
| ||
int i = 9; sNumber = String.format("%04d", i); |
liefert "0009".
Dialoge (Input Specification)
Codeblock |
---|
JA/Nein - Dialog if (showDialogEmail("Soll an die Kundenemail: " +email1 +" eine Email verschickt werden?")) { // Email wird verschickt } private boolean showDialogEmail(String msg) throws BusinessException { if (InputContext.isSupported()) { Integer iValue =(Integer)InputContext.get("wEmailverschicken"); if (iValue == null) { InputSpecification spec = new InputSpecification(InputSpecification.CONFIRM_YES_NO, "wEmailverschicken", msg); throw new InputRequiredException(spec); } else { return (iValue.equals(1)); } } else { throw new BusinessException("Nicht unterstützt."); } } |
Überblick
Inhalte