3

I have a date string in the form month/day/year, i want to get only the day of the week for the selected date, and then match the day with my db for further processing. Kindly help

Saba Nazir
  • 119
  • 1
  • 1
  • 7

4 Answers4

1

Use the class GregorianCalendar, it has method that can help you

Gabriel Negut
  • 13,860
  • 4
  • 38
  • 45
morgano
  • 17,210
  • 10
  • 45
  • 56
0

if dateString contains the date in form month/day/year, you can split it into an array as follows:-

String[] splitDate = dateString.split("/");

The day would be the 2nd element of the splitDate Array

String day = splitDate[1];
shashank93rao
  • 131
  • 1
  • 1
  • 8
0

Use: java.util.GregorianCalendar class. there is constructor with date,month,year as parameters. Then there is a method to get(Calendar.DAY_OF_WEEK);

Rajath S
  • 169
  • 1
  • 14
0

Thankyou so much. i m doing it like this

cal.set(Calendar.YEAR, cyear);
cal.set(Calendar.MONTH,cmonth); //week 37 of year 2010
cal.set(Calendar.DAY_OF_MONTH,cday);
int i= cal.get(Calendar.DAY_OF_WEEK);
Saba Nazir
  • 119
  • 1
  • 1
  • 7