Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Get day of the week from date?

How can i format the date to be like this

Mon, 27 Nov 2011

    public static String sFleTimeToDate(double ft) {
           double date = ft / 10000 - 11644455600000L;
           date += TimeZone.getDefault().getOffset((long) date);
           return DateFormat.format("ddd, dd MMM yyyy", new Date((long) date)).toString();
}

but this function return

027, 27 Nov 2011

like image 680
Basbous Avatar asked Jan 24 '12 13:01

Basbous


2 Answers

You can change your DateFormat.format to

 DateFormat.format("EEE, dd MMM yyyy", new Date((long) date)).toString();
like image 156
Henrique Miranda Avatar answered Nov 15 '22 00:11

Henrique Miranda


For getting day in week you have to use EEE

SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy);

You can create any format as you desire just have a look at this Tutorial.

like image 31
Lalit Poptani Avatar answered Nov 14 '22 23:11

Lalit Poptani