2012-10-15 10 views
9

Voglio impostare data in formato come questo,Come formattare la data con il giorno in Android?

Friday, March 4, 2012 3:15 AM 

sì, io sono sapere di questo

SimpleDateFormat parseFormat = new SimpleDateFormat("MMMM dd,yyyy hh:mm a"); 
    Date date =new Date(); 
    String s = parseFormat.format(date); 

ma non so che cosa è opzione per mostrare il giorno, ti prego, aiutami. Grazie!

risposta

16
 SimpleDateFormat parseFormat = new SimpleDateFormat("E MMMM dd,yyyy hh:mm a"); 
    Date date =new Date(); 
    String s = parseFormat.format(date); 

consultare questo per maggiori dettagli SimpleDateFormat

0

Basta usare E come formattatore

Es:

SimpleDateFormat parseFormat = new SimpleDateFormat("EEEE, MMMM dd,yyyy hh:mm a");

+0

Grazie mille ........... –

7

nella stringa di formato, utilizzare "E" per il nome breve (Dom, Lun, Mar, ecc), o "EEEE "per le parole complete (domenica, lunedì, martedì, ecc.).

Vedere anche here.

+0

Grazie! Un sacco........ –

0
public static String currentDateTime(String dateInParse){ 
    SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd,yyyy hh:mm a"); 
    Date date = null; 
    try 
    { 
     date = sdf.parse(dateInParse); 
    } 
    catch(Exception ex) 
    { 
     ex.printStackTrace(); 
    } 
    SimpleDateFormat formatter = new SimpleDateFormat("EEEE MMMM dd,yyyy hh:mm a"); 
    String newFormat = formatter.format(date); 

    return newFormat ; 
} 

qui dateInParse è la data in stringa formato è come come sdf.

Problemi correlati