+ 5

Java Days calculator

Hi guys. Uhm, I remember last year, (2017, first year of varsity) being given an assignment to create a day calculator (in c#) that would calculate the number of days left from the current day until the beginning of the holidays e.g 1 Dec 2018 (future date) and test whether the user had entered a date in the future. If not, alert the user to enter a correct date in the future. I've been thinking to do the same in java. I'm just not familiar with the language, started learning recently. Care to help?

24th Feb 2018, 3:44 PM
Kaelo Motsatsi
Kaelo Motsatsi - avatar
5 Respostas
+ 4
Why, yes it does! I personally have never used Android Studio (even though I want to start), but it does seem to be capable of displaying a date/time picker. Here's a tutorial on how to do so - http://abhiandroid.com/ui/datepicker
24th Feb 2018, 5:28 PM
Faisal
Faisal - avatar
+ 3
One thing that may help you is the Date library, which allows for you to retrieve the current date on the device being used and even just mess around with returning your own dates and times. It can be imported by using the java.util.Date import method at the beginning of your code, allowing you to use any function within the library. If you want to check it out more, here's a website that explains quite a bit about it - https://www.tutorialspoint.com/java/java_date_time.htm Hope this helped! d:
24th Feb 2018, 4:04 PM
Faisal
Faisal - avatar
+ 2
thank you.. I'll look into it. I'd prefer using the Date time picker for the user's input of the future date though. Does Android Studio have such?
24th Feb 2018, 5:16 PM
Kaelo Motsatsi
Kaelo Motsatsi - avatar
+ 2
Well, it's the easiest way to approach it and the easiest way for the user to input the data, don't you think?
24th Feb 2018, 7:44 PM
Kaelo Motsatsi
Kaelo Motsatsi - avatar
+ 2
Yeah, it definitely seems to be much more efficient than the other method. d:
24th Feb 2018, 7:52 PM
Faisal
Faisal - avatar