Reputation: 4958
I need to get Launch Pad Logged in user's Date Format from settings.
I followed methods in link
And it has methods such as
getImage():sap.ui.core.URI
getShowPopupIndicator():boolean
getUsername():string
This is how I set Date format in Fiori Launch Pad
And according to ibn's answer, I tried
sap.ui.getCore().getConfiguration().getFormatSettings().getDatePattern("medium");
But it returned undefined
The thing is when I first set date format using
sap.ui.getCore().getConfiguration().getFormatSettings().setDatePattern("medium","mm/dd/yyyy");
It returns "mm/dd/yyyy"
otherwise, it returns undefined ... And API reference says "Returns the currently set date pattern or undefined if no pattern has been defined." Link
How can I get user's date format from settings?
Upvotes: 2
Views: 3359
Reputation: 5018
For getting the current date format which has been set for the current user in the Fiori use the following syntax:
var oDateFormat = sap.ui.core.format.DateFormat.getDateInstance();// also getDateTimeInstance() exist
var oDate = oDateFormat.format(new Date());
Then you can use the oDate
object for setting date anywhere, for example in a DatePicker
.
oDatePicker.setValue(oDate);
Upvotes: 1
Reputation: 1034
You can use
sap.ui.getCore().getConfiguration().getFormatSettings().getDatePattern("medium");
Upvotes: 1