Subject Re: [Firebird-Java] Inserting only date-part of timestam with Jaybird and Hibernate
Author Maaartin-1
On 10-11-17 10:51, Mark Rotteveel wrote:
>> Thanks Mark for your suggestions.
>>
>> To get the desired result I used #3:
>>
>> Date today = new Date();
>> java.sql.Date now = new
>> java.sql.Date(today.getYear(),today.getMonth(),today.getDay());
>>
>> Only this gave me the expected result of having only dates in my
>> timestamps.
>> (new java.sql.Date(System.currentTimeMillis()) resulted in having a
>> time-part stangely)
>
> Hmm, that is actually weird. But I have to admit I didn't try it and
> only based that suggestion on the Javadoc of java.sql.Date which claims
> it will set the time portion to zero (in the current timezone).

It doesn't, there's just a comment about doing it in java.sql.Date:

public Date(long date) {
// If the millisecond date value contains time info, mask it out.
super(date);
}

Everything concerning Date etc. in Java is seriously broken by design.
However, doing nothing may suffice, assuming that the SQL-Driver
(Jaybird) masks it out, which it should do but doesn't seem to. Isn't it
a bug?

Maaartin.