• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using Date in servlet  RSS feed

 
Syam Veerakumar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all I am checking the date which is posted from a form to servlet while i use Date class it says its depricated since i know i have to use Calender class i am not sure how to use it.I have given the code below can any one help in this regard.

Date sysDate = new Date();
int recpDateDD = Integer.parseInt(request.getParameter("receiptDateDD"));
int recpDateMM = Integer.parseInt(request.getParameter("receiptDateMM"));
int recpDateYY = Integer.parseInt(request.getParameter("receiptDateYY"));
if( sysDate.after(new Date(recpDateYY,recpDateMM,recpDateDD)) ){
ErrVect.addElement(" Receipt Date should not Exceed Current Date.");
}
Thanks,
Syam.
[This message has been edited by Syam Veerakumar (edited October 23, 2001).]
 
Dmitriy Pavlyuk
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may use this code:
if( sysDate.after((new GregorianCalendar(recpDateYY,recpDateMM,recpDateDD)).getTime()) ){
ErrVect.addElement(" Receipt Date should not Exceed Current Date.");
}
 
Syam Veerakumar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply can I use the following code to get System Date.
GregorianCalendar sysDate = new GregorianCalendar();
 
Syam Veerakumar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u so much Dmitriy,its working fine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!