i get time field from a database table. But may i know how to convert it into 24 hour minutes and second. simpledateformat("hhmmss") is not working. Is there any other simple java method doing it?

Show your code (and use code tags). Also, is it a Date, DateTime, or TimeStamp field in the Database.

Be aware though, that if your calling getDate on the field, that it will return only a Date, the time will be 00:00:00.

Check the doc for SimpleDateFormat. You want to use "HHmmss" instead of "hhmmss".

Show your code (and use code tags). Also, is it a Date, DateTime, or TimeStamp field in the Database.

Be aware though, that if your calling getDate on the field, that it will return only a Date, the time will be 00:00:00.

if i do it this way
String time = x.getTime(1).toString();

will it 24 hour minutes and second in the format 001236 ?

Check the doc for SimpleDateFormat. You want to use "HHmmss" instead of "hhmmss".

just tested....it works !! thanks
still need to try it in DB2

What is the sql type of the column in your database?
Perhaps you can alter the query in order to format the column and return it as String:

select TO_CHAR(date_col,'DD/MM/YYYY HH24 : MI : SS') from table tbl;

The date_col would be type DATE at the table and when you get the column from the ResultSet you can use: rs.getString();

I think that if it is type TIME then use only: HH24 : MI : SS in the TO_CHAR method

... i'd say to have a method that reads the time from thr base then get the HOURs convert it IF needed ex:

public Date convert(Date time){
int mask 12;
if (time <= mask)
time=time+12

... i'd say to have a method that reads the time from thr base then get the HOURs convert it IF needed ex:

public Date convert(Date time){
int mask 12;
if (time <= mask)
time=time+12

You declare time as Date and mask as int ?????? Can you please explain what do you mean, because your code doesn't make any sense.

Thanks javaAddict.....got your idea........your method works.....

select TO_CHAR(date_col,'DD/MM/YYYY HH24 : MI : SS') from table tbl;

... i'd say to have a method that reads the time from thr base then get the HOURs convert it IF needed ex:

public Date convert(Date time){
int mask 12;
if (time <= mask)
time=time+12

This code is not valid and appropriate solutions have already been provided.

Don't worry too much about this guy. He has proven on another forum that he doesn't know what he is doing and either just cannot understand what you try to tell him, or simply ignores it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.