java - What class should I use for Date's in Android? -


i'm making app android, i'm unsure class best use.

what need dates i'm working things such comparing dates, getting difference between them, , date calculations (such adding/subtracting small period of time such 2 weeks or month given date).

i know standard date class in java api horrible, i'm wondering classes recommended?

i've seen gregoriancalendar class, , joda time library. however, read on post due size of joda time library, wasn't recommended apps.

any appreciated. ^^

edit: upon comment 404notfound, decided go calendar interface. due calendar interface automatically using best implementation of based on locale , time zone of user's device. make more flexible on implementation of gregoriancalendar (or other specific implementations) in terms of places can roll out to.

hope helpful else same conundrum!

edit #2: after further link provided nguyễn hoài nam, i've went threetenabp library, it's wrapper new time class featured in java 8, , prove more fluent in use calendar approach.

i recommend looking @ threetenabp library better alternative (as that's i've migrated similar application use). library backport android of threetenbp, in turn backport java 6 of latest java 8's date time api (same creator). (i encourage review java 8 date time api pros/cons out there first.) note threetenbp provides similar verbs joda time won't have hard time migrating them. last, noticed in lib, method count, lib size etc problem in android. lib solve that.

edited add usage guide.

  • add lib build.gradle

    compile 'com.jakewharton.threetenabp:threetenabp:1.0.1'

  • create application class if didn't. example, package is: com.example.app, place new file named myapplication.java under package. snippet here myapplication.

  • update androidmanifest.xml <application> tag: add line right under <application : android:name=".myapplication"

  • run app.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -