0

I am currently working on a calendar application using Caldroid and the date that Caldroid returns looks like this:

Fri Jun 17 12:31:00 GMT+07:00 2016

I just need to extract the date from it like for example:

17-06-2016

How am I supposed to do that?

Shadab Ansari
  • 7,022
  • 2
  • 27
  • 45
user3401369
  • 87
  • 1
  • 8

2 Answers2

3

Try this -

    DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
    DateFormat df2 = new SimpleDateFormat("dd-MM-yyyy");

    try {
        //This will give you the desired output
        df2.format(df.parse("Fri Jun 17 12:31:00 GMT+07:00 2016"));
    } catch (ParseException e) {            
        e.printStackTrace();
    }
Shadab Ansari
  • 7,022
  • 2
  • 27
  • 45
2

You can use SimpleDateFormat. Please refer to the address http://tutorials.jenkov.com/java-internationalization/simpledateformat.html

PhungHV
  • 82
  • 2