tarzanbappa
tarzanbappa

Reputation: 4958

SAP Fiori Get Launch Pad User Date format

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

enter image description here

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

Answers (2)

MJBZA
MJBZA

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

I.B.N.
I.B.N.

Reputation: 1034

You can use

sap.ui.getCore().getConfiguration().getFormatSettings().getDatePattern("medium");

Image of Console after change configuration on SU01

Upvotes: 1

Related Questions