Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-01-2007, 01:44 PM
Member
 
Join Date: Aug 2007
Posts: 1
ironballs is on a distinguished road
Date as String to TimeStamp
Hi,
I'm trying to convert date & time presented in String to TimeStamp object (so it could be written to DB).
I've created a small program to test this, but the problem is, that every time, when I check the resulting Timestamp object the date part always resets to '01' - it's the same thing when writtne to the DB:


String t2,st = "16/08/2007 09:04:34";
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy hh:mm:ss");
Date date = sdf.parse(st);
Timestamp timestamp = new Timestamp(date.getTime());
t2 = timestamp.toString();
// T2 will show: "2007-01-16 09:04:34.0"

anyone knows how to solve this issue ?

thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-01-2007, 02:43 PM
Member
 
Join Date: Jul 2007
Location: England, Bath
Posts: 47
shanePreater is on a distinguished road
change the first mm to MM as mm represents minutes not Month which is represented by MM
__________________
Shane Preater -
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between current date and anothe date vijay balusamy New To Java 1 04-16-2008 05:15 PM
Timestamp in SQL format Java Tip Java Tips 0 02-10-2008 12:37 PM
Converting Epoch to string Date amyedwards New To Java 3 12-14-2007 11:33 PM
Using java.util.Scanner to search for a String in a String Java Tip Java Tips 0 11-20-2007 05:59 PM
String to Date conversion javaplus New To Java 2 11-06-2007 08:16 PM


All times are GMT +3. The time now is 08:36 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org