• 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

dates and times as integers in a query string

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to insert dates and times into a database. The dates are displayed from the database as for example

March 1, 2005 - but in the database the id is 1
April 1, 2005 - and for April the id is 2

I want the users to see March 1, 2005 which I do now but need to pass 1 to the query string and 2 etc. How can I change the dates in the background using JSP to the Integer of 1 for March and 2 for April or for that matter whatever date the user clicks on? My servlet needs to see the dates and times as an integer or it wont work.

Any help would be appreciated.
[ December 04, 2004: Message edited by: Kirk Martin ]
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not completely clear on what you are wanting, but my suggestion would to use a if else statement (actually, a switch statement, but I don't remember the exact syntax). Pull out the month, and try something like this:



so on and so forth. Also, it is best to put logic code in a class outside of the JSP and call it from the JSP. And always remember to include a default case, just in case something breaks down, the whole application will not fail.
 
Kirk Martin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What i'm wanting is to pass 1 or 2 or 3 or 4 etc. (these are the dateID numbers in the database) depending on what date the user clicks on in the form. So for example if you (Logan Owen) clicks on April 1, 2005 in the query string it will be number 2 instead of April, 1 2005. The reason is because in my servlet (I'm using switch and a case to do the processing) I have for the dates - ds.setDateID(Integer.parseInt(request.getParameter("dateID")));

If you have any questions or a solution let me know.

Thanks

Kirk
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kirk,
You can set the value in your JSP. For example,
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our JSP forum as this is more about JSP than JDBC.
 
reply
    Bookmark Topic Watch Topic
  • New Topic