convert from Date to number in Java

Asked

Viewed 49 times

0

I have a field in the Mysql Date database and within a function modelPie.set(String, number) I want to bring this field but java says it cannot convert from Date for Number.

  • Welcome to [en.so]. It would help if you post the code snippet that error and the error message.

1 answer

1

Friend the question is quite incomplete, but I will try to answer objectively.

Java does not make the conversion implicit, only in the case of inheritances. As the class of number and date has no relation it even complains.

Use the method getTime class Date.

modelPie.set("Nome", data.getTime());

Browser other questions tagged

You are not signed in. Login or sign up in order to post.