| Author |
conversion of date from dd/mm/yyyy to yyyy/mm/dd
|
zaheer agadi
Ranch Hand
Joined: Jan 02, 2006
Posts: 32
|
|
hi i m using my mysql database and using stored procedure for inserting values into db my problem is mysql only takes values in the format yyyy/mm/dd but i m inserting as dd/mm/yyyy fro which i m using a third party calnedar how do i insert the date thnx
|
CHEERS<br />Zaheer SCJP(1.4)
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
Well, date is a date, no matter what is the format. Date should be inserted as date. The data type for a date should be a date. Formatting stuff can be handled in code. You can use SimpleDateFormat class to format the date. Now where is your problem? Please elaborate.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
Moved to Java In General (Beginner)
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
If you're inserting to a database with a prepared statement you can pass a Date object as a parameter to the statement and JDBC will handle all that formatting stuff for you. Pretty slick. If you're converting one string format to another string format you have a couple choices. One would be to use a SimpleDateFormat object to parse one string into a Date, and another SimpleDateFormat object to format the Date into another String. If you're going to do millions (really, many maillions) it might be faster to use substrings and concatenation. Any of that sound like something you want to do? If you get stuck, post some not-quite-working code here and we'll help you get it going.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Originally posted by Stan James: If you're going to do millions (really, many maillions) it might be faster to use substrings and concatenation.
Or use a regular expression, which is probably somewhere in between, performancewise.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: conversion of date from dd/mm/yyyy to yyyy/mm/dd
|
|
|