Best Practice

Input Formating und Validierung

Date Format

Number Format

Date Format

var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance({
    pattern: "EEE, MMM d, yyyy"
});

oDateFormat.format(UI5Date.getInstance()); //string in the same format as "Thu, Jan 29, 2017"

Currency Format

Währungen können auch individuell formattiert werden.

// "NumberFormat" required from module "sap/ui/core/format/NumberFormat" 
var oCurrencyFormat = NumberFormat.getCurrencyInstance({
    currencyCode: false
});

oCurrencyFormat.format(1234.567, "USD"); // returns $1,234.57
oCurrencyFormat.format(1234.567, "JPY"); // returns ¥1,235

Oder im XML View

<m:Text text="{ parts: [ {path: 'TotalPrice'},
                         {path: 'CurrencyCode'}
                        ],
                type: 'sap.ui.model.type.Currency',
                formatOptions: {showMeasure: true, currencyCode: false}
}" />

- xyb