timozattol / project-radin

Project Radin is an expense management Android application that was build during EPFL's Software Engineering 2014 course.
2 stars 2 forks source link

How do we store dates (in Java objects) ? #59

Closed timozattol closed 10 years ago

timozattol commented 10 years ago

AArg I've been reading a few forums now no-one seems to agree, how to store dates and time in Java ? The "Date" class has almost all of its methods deprecated, "Calendar" seems to be a lot of overhead for nothing (and lots of forums said that we shouldn't use it either), who knows a simple way to store a dateandtime ?

Thanks

http://stackoverflow.com/questions/1404210/java-date-vs-calendar/1404216#1404216 http://stackoverflow.com/questions/344380/why-is-january-month-0-in-java-calendar/344400#344400 etc.

PS: I don't want to use "joda time" since it's not part of the standard java API

ireneu commented 10 years ago

Can't really help you here. Pity, joda time is quite simple and works very well.

How do you want to create/use the dates ?

julied20 commented 10 years ago

For our semester project last year in Java, we created a new Date class, you can take a look at what we've done if you want. After, it really depends on how do you want to use them.

timozattol commented 10 years ago

Well it's in the Transaction Model, so we'll probably want to print them, and use them to sort the Transactions...

ireneu commented 10 years ago

If it's only for sorting the transactions, longs in the YYYYMMDDhhmmss format can be sorted by size so that they appear in temporary order But having a Date model will make the code better : )

timozattol commented 10 years ago

Okay, thanks! With your advice, I imported Joda-Time in the libs, it works well. I also think it's a lot better to have an actual Date (DateTime) class.