3

I'm honestly kinda lost.

I need to store date & time for simple usage, for example storing in the database, sectioned recycler view etc, but there are too many options of how to save data&time, and every article say one is better than the other.

There are Date, Calendar, LocalDateTime, Instant etc

My question is what is the current best way of storing date and time?

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
Masksway
  • 205
  • 3
  • 11
  • In my opinion you should store timestamp as it is standard. you can convert it back to date time later – Ali Ahmed Oct 13 '20 at 10:38
  • Of course I'm converting this before I insert this into the DB, maybe I wasn't very clear in my question but I meant storing date&time in the model for in app usage @AliAhmed – Masksway Oct 13 '20 at 10:41
  • 1
    As i said, store it as Timestamp in model. and convert it in a format you want to display later – Ali Ahmed Oct 13 '20 at 10:46

1 Answers1

1

Best way to store date and time in millisecond. Convert your date and time to millisecond and store it.

Anand Jain
  • 2,365
  • 7
  • 40
  • 66