• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can we get the day when we give date  RSS feed

 
rajaa reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I need some help.
how can we get the day when we give the date.for example when we give the date as 21/12/2006.i want the today's day(thursday or 4).

thanks
Rajaa.
 
Ajith George
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use getDay() method of java.util.date.

Returns the day of the week represented by this date. The returned value (0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday) represents the day of the week that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.
 
rajaa reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
not that. if i give any date i want the day corresponding the date.
also getDay() is Deprecated.is there any solution?
thanks
rajaa
 
Ajith George
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what? Use any of the java.util.date constructors to intitialize it with your date. Then use the getDay() to get the corresponding day.

It's deprecated, so you can also try GregorianCalendar(int year, int month, int date)
 
rajaa reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
sorry yaar i am not getting that can you please send me the code.
thanks
 
Ajith George
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try to find it out from the sample class i put here.



 
rajaa reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry yaar,I dont want this.if i give date as 18/12/2006 i want output as monday or 1.
thanks
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many simple ways to do this without using deprecated methods. One is:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!