Format Date as Day of Week

Is there a date format to display the day of the week in java?

This should display 'Tue':

new SimpleDateFormat("EEE").format(new Date());

This should display 'Tuesday':

new SimpleDateFormat("EEEE").format(new Date());

This should display 'T':

new SimpleDateFormat("EEEEE").format(new Date());

So your specific example would be:

new SimpleDateFormat("yyyy-MM-EEE").format(new Date());

Format current date to show day of the week

This does what you want

Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("EEE, MMM d, yyyy");
String strDate = sdf.format(cal.getTime());
System.out.println("Current date in String Format: " + strDate);

Where strDate can be displayed in your textView or whatever

excel : format dates so that they include the day of the week in full letters

Right click on the cell - cell formating, then select date on the left pane, and select format type on the right pane.
Or is this a programing question ?

insert day of the week based on YYYY/MM/DD format

If you're using VBA, you need the function Format:

Dim StartDate As Date
Dim DayOfWeek As Date
Dim i As Integer

mbox = InputBox("Enter Start Date", "Enter Start Date")

If IsDate(mbox) Then
StartDate = CDate(mbox)
For i = 0 To 13
Cells(i + 2, 3) = Format(StartDate + i, "dddd")
Cells(i + 2, 4).Value = StartDate + i
Next i
Else
MsgBox "Please Enter a Date"
End If

If you want the routine to display the 14 days including the day entered, use this loop instead:

For i = 0 To 13
Cells(i + 2, 3) = Format(StartDate + i, "dddd")
Cells(i + 2, 4).Value = StartDate + i
Next i

How do I get the day of week given a date?

Use weekday():

>>> import datetime
>>> datetime.datetime.today()
datetime.datetime(2012, 3, 23, 23, 24, 55, 173504)
>>> datetime.datetime.today().weekday()
4

From the documentation:

Return the day of the week as an integer, where Monday is 0 and Sunday is 6.

How to show day of the week + format Date

This code will format calendar object to "Thursday, Feb 20 2014"

SimpleDateFormat format = new SimpleDateFormat("cccc, MMM dd yyyy");
String formatDate = format.format(cal.getTime());

See SimpleDateFormat at the official Android docs for more information.



Related Topics



Leave a reply



Submit