DateTime datatype -> SimpleDateFormat

K

Kabal

Is there a easier way to accolish the following:

SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);

Date date = new Date(Timestamp.valueOf(COLUMN_FROM_A_TABLE_CONTAINING_DATETIME_DATETYPE).getTime());

simpleDateFormat.format(date);
 
K

Kabal

Harald Hein said:
Timestamp is a Date. Read the API documentation.

Thanks for the response Captain Obvious :/

But I was referring to DateTime datatype of a relational database.
 
R

Roedy Green

Thanks for the response Captain Obvious :/

But I was referring to DateTime datatype of a relational database.


You rude bastard. He gave you useful information based on your
question. If your question was unclear, that is not his fault.

Why should ANYONE ever answer questions for you again if that is the
way you treat people?
 
K

Kabal

Roedy Green said:
You rude bastard. He gave you useful information based on your
question. If your question was unclear, that is not his fault.

Why should ANYONE ever answer questions for you again if that is the
way you treat people?

Not quite sure I could have worded it any clearer. As for you, if you
going just act like a 10 year don't bother replying. Believe me I
don't care to see your worthless response and neither does anyone
else.
 
P

P.Hill

Kabal said:
Not quite sure I could have worded it any clearer. As for you, if you
going just act like a 10 year don't bother replying. Believe me I
don't care to see your worthless response and neither does anyone
else.

Mr Kabal,

I think you need to back off a little. Several people were trying to help.

One point that was being made is that if you are using JDBC connection and a
ResultSet you can do a myResultSet.getDate( column# ) or getTime or
getTimeStamp. After that you have to do no more conversion, you can just
make a String. The only possible gotcha with the java.sql.TimeStamp
as the API docs tell us is...

" Due to the differences between the Timestamp class and the java.util.Date
class mentioned above, it is recommended that code not view Timestamp values
generically as an instance of java.util.Date. The inheritance relationship
between Timestamp and java.util.Date really denotes implementation inheritance,
and not type inheritance."

What's that all about? Timestamps have nanoseconds in them and ignore
the milli part of the Date class.

But I see you had a "DATETIME" and you used:
Date date = new
Date(Timestamp.valueOf(COLUMN_FROM_A_TABLE_CONTAINING_DATETIME_DATETYPE).getTime());

which uses Timestamp.valueOf

Personnally would have just asked the ResultSet to do the conversion for me by
going for the datatype I needed, so I would have gone back to the
ResultSet and instead of starting with the String from the ResultSet
done a getDate as the original reply suggested. Is there some part of
your architecture that makes that a problem?

Have I properly identified what you are trying to do?

I hope that helps, and next time try not to call repliers names BEFORE you
get the answer you are looking for. Also, as it says in a series
on Netiquette Tips, http://email.about.com/cs/netiquettetips/qt/et123101.htm
be careful with irony.

Cheers,
-Paul
 
T

Tor Iver Wilhelmsen

Not quite sure I could have worded it any clearer. As for you, if
you going just act like a 10 year don't bother replying. Believe me
I don't care to see your worthless response and neither does anyone
else.

Being an asshole when people are trying to help spells failure.

Good luck with your future career as a hobo.
 
D

David Postill

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(e-mail address removed) (Kabal)
wrote:

| > On 7 Dec 2003 06:52:18 -0800, (e-mail address removed) (Kabal) wrote or
| > quoted :
| >
| > >> Timestamp is a Date. Read the API documentation.
| > >
| > >Thanks for the response Captain Obvious :/
| > >
| > >But I was referring to DateTime datatype of a relational database.
| >
| >
| > You rude bastard. He gave you useful information based on your
| > question. If your question was unclear, that is not his fault.
| >
| > Why should ANYONE ever answer questions for you again if that is the
| > way you treat people?
|
| Not quite sure I could have worded it any clearer. As for you, if you
| going just act like a 10 year don't bother replying. Believe me I
| don't care to see your worthless response and neither does anyone
| else.

Well come to my killfile. You have the honour to be the first person added
for about a year.

<davidp />

- --
David Postill

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3 - not licensed for commercial use: www.pgp.com
Comment: Get key from pgpkeys.mit.edu:11370

iQA/AwUBP9TTenxp7q1nhFwUEQIO8QCfXeDnhAkM9g2nTMiGP/lz36GfsVIAoLWL
ABbExHfTfj1OguoavCHmm9Sa
=KZXc
-----END PGP SIGNATURE-----
 
K

Kabal

Thanks for the response Captain Obvious :/

But I was referring to DateTime datatype of a relational database.


I apologize ... not looking to start a war here.
 
R

Roedy Green

Not quite sure I could have worded it any clearer.

Who the hell you do you think your are: the Queen Of England? You are
NOT entitled to ANY response. People offer you what they can in good
faith. And you spat on someone trying to help you. In a while I will
plonk you to make sure I never inadvertently offer you any help. I
suggest others do the same.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top