In my database, I have value set as 9/28/2010 11:30:00 PM.
Now I am making use of dataResultSet.getTimestamp(3) which gives me a value as 2010-09-28 23:30:00.0. I want my result to be same as that of database values.i.e, I want the time to be 11:30.
What could be solution for this? Can anyone help me with this?
Thanks in Advance.
Actually, I suspect that in your database, the value is set as
1285716600. What you likely mean is that your database client is displaying this value as “9/28/2010 11:30:00 PM”.This is entirely a matter of formatting – a Date represents a specific instant in time, and is not a String. Rather, there are multiple potential ways of converting a Date into a String representation of it. In particular, note that you don’t get the date in any particular format from the database; it arrives as a Date, and it’s up to you to format it.
How are you converting this date into a String? If you want a particular output style, you should use the SimpleDateFormat class (or equivalent).