Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 24th, 2005, 03:53 AM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Save date in to a table

Hi,
I am trying to save some fields in a table, one field with type Date.
It only accepts date with the following format (01-Jan-05). I am reading the date as a string (24/09/2005) and then convert it to date. but i do not know to convert it to the following format (24-Sep-05) to store it in the table??
Please I need help urgently. This is my code :
 <% String issuedate = request.getParameter("issuedate");
DateFormat format = new SimpleDateFormat("dd/MM/yyyy");
myIssueDate = format.parse(issuedate);
mindecree.setIssueDate(new java.sql.Date(myIssueDate.getTime())); %>



 
Old September 24th, 2005, 07:57 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not have code to hand, but I think you can add a parameter

SimpleDateFormat(DateFormat.MEDIUM);

Which will write out the format you want, not sure if I have got the right method here (i.e. whether this works with SimpleDateFormat) but if you google around for DateFormat.MEDIUM I think you will find what your after

 
Old September 25th, 2005, 05:36 AM
Registered User
 
Join Date: Sep 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you angrycat,
I've tried it but it does notwork...!!!

 
Old September 26th, 2005, 04:49 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry,

should have told you to try this first:

DateFormat format = new SimpleDateFormat("dd/MMM/yyyy");

will return short description of month

DateFormat format = new SimpleDateFormat("dd/MMMM/yyyy");

Will return full name, you can mess with YY in the same way, does this help??






Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a List Box with Table Names & Table date hewstone999 Access VBA 1 February 27th, 2008 10:10 AM
how to save queries in the table benz_jie2005 SQL Server 2005 3 June 7th, 2007 04:48 AM
Using "now()" to save date and time to database misskaos Classic ASP Basics 12 October 11th, 2006 05:01 PM
How to save a table in another name rohan1958 Access 3 January 31st, 2005 09:36 AM
Save universal date format einarhansen Classic ASP Databases 2 November 26th, 2003 05:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.