• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compare date format

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
have a good day......

now i have two text box in the jsp page. i enter date using datepicker(ready made java script).

date enter in text box, formats like

in one textBox,
example : "10-jul-2005 10:12 PM"

in second textbox,
example : "09-jan-2004 10:12 AM"

SO how can i compare this date format ?

please give some suggestion.

i m waiting your reply..

Thanks & regards,
Nimish Patel
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to construct Date objects from your values. The relevant constructor has the form "new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )", where you need to fill the parameters with the corresponding parts of your string. You can extract the pieces of your string using regular expressions or using the standard String functions. Once you have two Date objects, you can compare the values you get from calling their getTime() methods.
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or after getting the date objects just compare them like you would any other variable
dat1 < dat2 dat1 > dat2.

Please note that dat1 and dat2 will be date objects.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic