androiddatetimedatetime-formatdatetimeformatinfo

Get current date time in the desired format


I would like to get the current date time in the following format

Tue, 20 Aug 2014 22:51:31 GMT

But I am finding it hard to get it to the format specifier e.g ddmmyy like that My doubt is what to specify Tue in symbolically like wise how to specify GMT symbolically.


Solution

  • Look into using a SimpleDateFormat.

    Edit:

    It looks like you might want the format string "E d MMM y H:m:s z".

    SimpleDateFormat format = new SimpleDateFormat("E d MMM y H:m:s z", Locale.US); String date = format.format(new Date());