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
Asked
Active
Viewed 118 times
3
-
split with "/" and take 1 element bu array[1] – shreyansh jogi Jul 01 '13 at 05:08
-
Possible duplicate of http://stackoverflow.com/questions/3949242/a-very-simple-java-code-to-get-date-of-a-week-day-but-very-strange-result-i-g – Juned Ahsan Jul 01 '13 at 05:08
-
the string is already split into three integers. i need the day of week – Saba Nazir Jul 01 '13 at 05:30
4 Answers
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