Why java.sql.Time.toString() adds hours?
Follow the simple a example
java.sql.Time t = new Time(1000);
System.out.println("Time t开发者_运维百科 =" + t);
This gives the following output:
Time t = 01:00:01
While I would expect:
Time t = 00:00:01
Could someone tell me how to get rid of the hours portion?
I think you should consider your current TimeZone
and check the API of the constructor
http://download.oracle.com/javase/7/docs/api/java/sql/Time.html#Time(long)
I expect you are living somewhere in Europe ;-)
The Time
object is normalized, i.e. the timezone of your JVM is taken into account.
Btw, instead of toString()
you might want to use DateFormat#format(Date)
and set the time zone on the DateFormat instance.
精彩评论