views:

49

answers:

0

Dear all, i just code a snippet code to get date time string as below:

public static String getCurrentDate(){
    Locale.setDefault(Locale.US);
    Date date = new Date();
    String strDate = date.toString();
    return strDate;
}

But problem is it take too long time (about 2 seconds) to convert from Date to string, Logs:

10-11 17:52:51.733: INFO/Resources(6835): Loaded time zone names for en_US in 2107ms.

Could you please give me a solution how to increase performance of this method

Update for solution: I just found an solution by tronman at topic: http://stackoverflow.com/questions/454315/how-do-you-format-date-and-time-in-android As below:

Date date = new Date();
java.text.DateFormat dateFormat =
    android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText("Time: " + dateFormat.format(date));