madan V
madan V

Reputation: 844

Android Convert String to Date

I am new to android deveolpment. I want to convert the String "Mon, 11 Feb 2013 08:00:00 CST" to a Date, and I also want to add this date to personal calendar.

Can anyone help me with this?

Upvotes: 0

Views: 171

Answers (3)

Nirav Tukadiya
Nirav Tukadiya

Reputation: 3417

Date d= new SimpleDateFormat("Yourdateformathere").parse("yourstringhere");

Upvotes: 0

Ketan Ahir
Ketan Ahir

Reputation: 6738

Try this...

    String time1 = "Mon, 11 Feb 2013 08:00:00 CST";
    String str="";
    Date date;
    try {
        date = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss z").parse(time1);
         str = new SimpleDateFormat("YOUR REQUIRED FORMATE").format(date);

        System.out.println("output DATE== "+str);

    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Upvotes: 0

Joshua D. Boyd
Joshua D. Boyd

Reputation: 4856

This question looks somewhat similar to: java string to datetime conversion issue

String d1String = "Mon, 11 Feb 2013 08:00:00 CST";
DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss z");
Date d1 = df.parse(d1String);

Upvotes: 1

Related Questions