[ANDROID]HOW TO GET SYSTEM DATE/TIME FORMAT BY LOCALE ?

private java.text.DateFormat mDateFormat;
private java.text.DateFormat mTimeFormat;
//// init values

// onCreate() for e.g

mDateFormat = android.text.format.DateFormat.getDateFormat(this);
mTimeFormat = android.text.format.DateFormat.getDateFormat(this);

// use
dateTimeString = mDateFormat.format(objectX.getTime()) + ” ” + mTimeFormat.format(objectY.getTime());

Advertisements

One response to “[ANDROID]HOW TO GET SYSTEM DATE/TIME FORMAT BY LOCALE ?

  • lla80Lasse

    Thanks a bunch this was easy to use.
    There is a single copy paste bug in your sample though, in case you want to tidy up.
    mTimeFormat = android.text.format.DateFormat.getDateFormat(this); should be mTimeFormat = android.text.format.DateFormat.getTimeFormat(this);

    Cheers
    Lasse

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: