0
I have doubts about the steps to manipulate dates.
The steps below are ok? Can I start studies?
- I have the attribute
Date
and I want to insert 2 days. - Convert
Date
inString
. - Convert
String
inCalendar
. - I make the code to manipulate the obtained date.
- Convert of
Calendar
forString
. - Convert of
String
forDate
. - Save.
because if I try to declare as Calendar
when saved from that mistake?
Unresolved Compilation problem: Type Mismatch: cannot Convert from
Code for more details:
// data em que o dinheiro foi entregue
@DateTimeFormat(pattern = "dd/MM/yyyy")
@Temporal(TemporalType.DATE)
private Date dataEmprestimo;
if I put private Calendar dataEmprestimo
, gives the error mentioned above.
Can you add the full stacktrace? Because this code is not making much sense with the error.
– user28595
I’m sorry if I can’t express myself well. but I’ll try to explain here.
– Cleriston Lincoln
When you try to run, do you pop a stack of errors? If yes, add it to the question, it is easier to locate the source.
– user28595
But why are you changing the type to Calendar? The annotation above indicates that it is Date, not Calendar.
– user28595
I have two doubts. 1º if the step by step to manipulate Date is correct. 2º because if I insert Calendar instead of Date error: Type Mismatch: cannot Convert from Calendar to Date] with root cause java.lang.Error: Unresolved Compilation problem: Type Mismatch: cannot Convert from Calendar to Date
– Cleriston Lincoln
if I remove @Temporal(Temporaltype.DATE) from right? by to Calendar?
– Cleriston Lincoln
Gives error because they are different types, and your annotation before the field says it is a Date field.
– user28595
I removed the note and it worked, a light started to appear here.... If it is not too much to ask, studying he asked to put the above note, why did he ask it? removing it implies that?
– Cleriston Lincoln