-2

I am developing an app which I want specifically to work Android API 23. I need to convert a UNIX timestamp into an actual time/date.

I have seen this solution which mentions SimpleDateFormat;

Convert unix time stamp to date in java

However, this is only supported in API 24 and higher. Any ideas on how to achieve this in API 23?

Fuller
  • 191
  • 1
  • 13
  • `SimpleDateFormat` [has been around since API Level 1](https://developer.android.com/reference/java/text/SimpleDateFormat.html) in general, and AFAIK all of those characters in the format string have as well. – CommonsWare Nov 14 '17 at 22:37
  • Read second line of the code in the [answer you linked to](https://stackoverflow.com/a/17433005/5221149): `new Date(unixSeconds*1000L)`. You have now converted the `unixSeconds` value into an **actual time/date**. The `java.util.Date` class *is* an actual time/date. `Thu, 27 Jun 2013 13:31:00 GMT` is not an actual time/date, but one *(of many)* text representations of an actual time/date. – Andreas Nov 14 '17 at 22:40
  • Thanks Andreas. You are correct, it is a duplicate of that, I was unaware I was using android.icu.text.SimpleDateFormat instead of java.text.SimpleDateFormat. – Fuller Nov 14 '17 at 23:00

1 Answers1

1

I think you may be using android.icu.text.SimpleDateFormat instead of java.text.SimpleDateFormat.

The former one was added in API level 24, the later one should work fine for all API levels.

premkamal
  • 133
  • 1
  • 7