Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date problem

 
Ikasari Widiyanto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a problem getting the day from a string. I hope somebody can help me.
here is my sample code:

String currDate = "";
String month = "";
String year = "";

for(int i=1;i<=31;i++){
currDate = year+"-"+month+"-"+i;
}

I want to display only the date without the month and the year and get the day of that particular date. how to solve this problem? can anybody help me? thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much to do with JSP, so I'm moving this off to the Java in General (intermediate) forum.
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ikasari,
I think you can use Gregorian Calendar..



You can refer to GregorianCalendar and Calendar API to get specific purpose you need...

Hope this helps...
Correct me if I am wrong
thanks
daniel
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DateFormatter class provides a slick way to do this with only a few lines of code:

(Disclaimer: This code does not come with any warranty, explicit or implied. It has not been compiled or tested, so use at your own risk.)

Consult the API docs for further details.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic