954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

convert date(string) to date (date time)

Mohandsa
Newbie Poster
11 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

OK, it seems you posted twice this time with more detail... this should be posted to the Javascript lists rather than JSP lists... BUT, a date object, or datetime is just a long numberic value... counting (usually) seconds or militseconds sine the "Epoc" time... usually Jan, 1 1970 00:00:00...

You have actually got what you need for a database, which you do an insert SQL with passing the long value to a datetime column, depending upon the database should result int he correct DB value being saved... you are confusing, I think, human readability with machine readability...

The first one you show, your string is human readable, while the number is how the machine will see it when it is properly converted to a date object...

In Java, when we have a date object which represents a given date, the toString will show it as 2007-04-01 while we insert it into the DB as a timestamp with setTimestamp(1, date.getTime())...
The getTime() method of the Date object returns a "long" with is just a number with lots of places... this is what the DB requires to understand the time....

Peace,

rgtaylor
Junior Poster in Training
88 posts since Mar 2007
Reputation Points: 10
Solved Threads: 2
 
vikki.v
Newbie Poster
1 post since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

var dat=Date.parse(date);
var theDate = new Date(dat);
//where dat is a long numeric sequence representing the epochmilliseconds.

ehassen
Newbie Poster
1 post since May 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You