Count of seconds since 1970
You have apparently mistaken a count of whole seconds since the epoch of first moment of 1970 UTC as a Julian day number. While both counts, these are entirely beasts.
A Julian day number is a count of whole or fractional days since January 1, 4713 BC, proleptic Julian calendar (November 24, 4714 BC, in the proleptic Gregorian calendar). The Julian day number for the date seen below, 2015-01-21
is 2457043
. Very different from the 1421832117
input seen in the Question.
java.time
Using the java.time framework built into Java 8 and later, we can easily convert your count of seconds into a date-time object. See Oracle Tutorial to learn about java.time. Much of the java.time functionality has been back-ported to Java 6 & 7 in ThreeTen-Backport and further adapted to Android in ThreeTenABP.
An Instant
is a moment on the timeline in UTC with a resolution of up to nanoseconds.
Instant now = Instant.now();
We can easily convert your count of seconds since start of 1970 UTC into an Instant
object.
long seconds = 1421832117L; // Count of whole seconds since start of 1970 UTC.
Instant instant = Instant.ofEpochSecond ( seconds );
You may want to view this by the wall-clock time of some time zone. Avoid using 3-4 letter abbreviations such as CET
as these are not true time zones, not standardized, and are not even unique(!). A proper time zone name is in the format of continent/region
.
ZoneId zoneId = ZoneId.of ( "Europe/Paris" );
ZonedDateTime zdt = ZonedDateTime.ofInstant ( instant , zoneId );
Dump to console.
System.out.println ( "seconds:" + seconds + " | instant: " + instant + " | zdt: " + zdt );
seconds:1421832117 | instant: 2015-01-21T09:21:57Z | zdt: 2015-01-21T10:21:57+01:00[Europe/Paris]