Strange problem with Calendar.getInstance ()

I am trying to save the current timestamp in an oracle table field defined as TIMESTAMP (6). I installed it using the setter method, which looks like this:

void org.samples.Invoice.setCreated(Calendar value) 

I set the field using Calendar.getInstance ().

 Invoice inv = new Invoice(); inv.setCreated(Calendar.getInstance()); 

I see that the entered timestamp has the correct date, but the time is always set as 00: 00: 00.0

Could you tell me what I'm doing wrong here?

+4
source share
2 answers

Maybe some other code calls invoice.getCreated() and sets the timestamps to zero. that is, a side effect of link passing

+1
source

From the answer in the comments.

Maybe some other code calls invoice.getCreated () and sets the time to zero. that is, it can be a side effect of passing by reference.
- Pangea November 8 at 22:02

0
source

Source: https://habr.com/ru/post/1444949/


All Articles