0

i am getting date from webservice

example: Wed, 29 june 2011 07:13:33

now i dont want to show full date with time zone just Wed, 29 june 2011 any one guide me how to achieve this?

any help would be appreciated.

UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278

2 Answers2

4
try{
      SimpleDateFormat format1 = new SimpleDateFormat("E ,dd MMM yy hh:mm:ss");   
      SimpleDateFormat format2 = new SimpleDateFormat("E dd-MM-yyyy");    
      Date date = format1.parse(dateStr);     
      System.out.println(format2.format(date));  
 }
 catch(exception e){}
Pank
  • 13,800
  • 10
  • 32
  • 45
Ayesha
  • 622
  • 2
  • 5
  • 17
2

This problem was already solved on StackOverflow here: Java string to date conversion (that is converting date string to java date)

Here is for your example:

String inDate="Wed, 29 june 2011 07:13:33";
    Date date;
    try {
        date = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss", Locale.ENGLISH).parse(inDate);
        System.out.println(date); //Wed Jun 29 07:13:33 CEST 2011
    } catch (ParseException e) {
        e.printStackTrace();
    }

Printing out date itself should be the least of your problems

Community
  • 1
  • 1
Bojan Kogoj
  • 5,321
  • 3
  • 35
  • 57