Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android java.time.LocalDateTime

Tags:

java

android

time

I am coding an Android application, which should receive a java.time.LocalDateTime object through an HTTP REST API that I developed in the server side.

The problem is that Android is still in Java 7, and java.time is only available in Java 8.

Having that said, what is the best way to represent a variable that contains date and time in Android? I prefer not to use sql.timestamp.

Thank you!

like image 668
Fabio Lanza Avatar asked Dec 23 '22 18:12

Fabio Lanza


1 Answers

Back-port

You could use the ThreeTen Android Backport which is an Android adaption to the original ThreeTen-Backport that backports much of the new java.time api back to Java SE 6 and SE 7.

See this answer to get started.

like image 103
Marvin Avatar answered Jan 07 '23 00:01

Marvin