Java Calendar class

Asked

Viewed 109 times

0

Good afternoon! The need arose to create a class that receives two dates in my activity, to make the code less dirty. I did some research and found the Calendar class, but I didn’t fully understand its operation. In my case, the user enters the start date of the rental of a car (day, month and year), and the date that the car will be returned (day, month and year). How can I do that? I’ve been trying for a while, but without any sense of class, it’s kind of hard. I program in bluej.

  • Good afternoon, you need to create two attributes in your class, we will call it rent, you will create the attribute dataResponse type Calendar/Date as you prefer, and the second attribute will be dataFinalAuthor with the same type of the first attribute, this helps you?

  • I used jodatime to do this, but for some reason is generating exception only at the initial date.

  • 2

    Please click [Edit] and enter the code, and also the exception message. With code it is easier to get an answer :-) Also read [Ask] and how to mount a [mcve]

  • And if you are using Java >=8 you no longer need Joda-Time (which is considered a "terminated" project), because now there is a API java.time. If you are using Java 6 or 7, java.time is not available, but instead of Joda-Time, you can use the Threeten Backport (a backport of Java 8, with most of the features available - in this answer has a short summary, in the section "Alternatives for Java < 8")

No answers

Browser other questions tagged

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