Total members 11895 |It is currently Sat Dec 21, 2024 6:52 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





In my application I am getting one String variable which holds date in
yyyy-mm-dd hh:mm:ss format. It is a String type and i would like to
convert it in sql.Date. TO convert in sql.Date type i am doing the
following:

1) I am getting value in format of yyyy-mm-dd hh:mm:ss, example
2008-03-19 19:44:58
2) i am trying like:

// stringDate is holding value 2008-03-19 19:44:58

DateFormat formater = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.util.Date parsedUtilDate = formater.parse(stringDate);
java.sql.Date sqltDate= new java.sql.Date(parsedUtilDate.getTime());

when i convert String date i get in parsedUtilDate: Wed Mar 19
19:44:58 IST 2008
and sqltDate is having value 2008-03-19

could you please help me to get date in same format in sqltDate (as it
is stringDate), 2008-03-19 19:44:58




Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

java.sql.Date.toString() only format to yyyy-mm-dd
Use java.sql.Timestamp instead.

_________________
Please recommend my post if you found it helpful


Author:
Proficient
User avatar Posts: 228
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : String to sql.Date
 Convert String to Date     -  
 Want start and end date of a month from current date     -  
 Formatting a Date with date()     -  
 Splitting a String Based on a Found String     -  
 check if string ends with specific sub-string in php     -  
 recursive string reversal- reverse string     -  
 check if string start with a specific sub-string in PHP     -  
 String token for string split     -  
 get next date by next day     -  
 Date in Java     -  



Topic Tags

Java Strings
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com