on 06-19-2007 2:52 AM
Hi All,
What is the difference between java.sql.date and java.util.date and which is more preferable to use .How to convert date from one form to another .
Thanks.
Go through these post:
http://lists.mysql.com/mysql/202513
How to convert:
Go through this link also: Good one to understand dates from Java
http://www.onjava.com/pub/a/onjava/2003/06/05/java_calendar.html
Regards,
Ashwani Kr Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
See this link... U can get different ideas in those conversations..
http://www.geekinterview.com/question_details/25307
Urs GS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
And also see This how to change date from one form to other..
How to change a date value from "java.util.Date" to
> "java.sql.Date"?
<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html">java.util.Date</a> date = // date
<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html">java.sql.Date</a> sqlDate = new <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html#Date(long)">java.sql.Date(</a> date.<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html#getTime()">getTime()</a> <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html#Date(long)">)</a>
Urs GS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi kl..
java.util.date is the java representation of date and time. Use this if you want to deal with dates or times in your java program (add, substract etc).
java.sql.date is for use only if you want to communicate with a SQL-Database like MySQL, MSSQL, PostGreSQL or so. Don't use it for the above mentioned stuff.
If you were using it for SQL-stuff, I guess you'd know that, so perhaps java.util.date is the right one for you.
I believe java.util.Date includes time (HH:MM:SS); java.sql.Date does not.
java.sql.Timestamp allows you to hold onto database timestamps down to the millisecond. - MOD
Urs GS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI ,
util date is a superclass of sql date.
util date will be in yyyy-mm-dd format while sql date is in yyyy/mm/dd format by default.
If u create a date type context variable in Webdynpro, it will be sql date by default. sql date is commonly used for date values in back end. If u import a date variable from an RFC, it will be of sql date..
Regards
Fahad Hamsa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Kl,
If you think from <b>WebDynPro and R/3</b> point of view Date is only <b>java.sql.Date.</b>
Depends upon Scenario we have to use
<u><b>Differences</b></u>
java.util.date is the java representation of date and time. Use this if you want to deal with dates or times in your java program (add, substract etc).
java.sql.date is for use only if you want to communicate with a SQL-Database like MySQL, MSSQL, PostGreSQL or so. Don't use it for the above mentioned stuff.
If you were using it for SQL-stuff, I guess you'd know that, so perhaps java.util.date is the right one for you.
believe java.util.Date includes time (HH:MM:SS); java.sql.Date does not.
java.sql.Timestamp allows you to hold onto database timestamps down to the millisecond. - MOD
Rgds
-SS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ki,
Check this thread.
To convert the date in to other format you have to use SimpleDateFormat.
Package
-
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Code:-
-
SimpleDateFormat smpdtFormat =new SimpleDateFormat("yyyy-MM-dd");
String vFr="";
vFr = wdContext.nodeProductDate().getElementAt(0).getAttributeValue("Validfr").toString();
prodElem.setValidFrom(new Date(smpdtFormat.parse(vFr).getTime()));
Check this threads...
Regards,
Mithu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.