how to convert timestamp value 444663422.631236 to date. I tried these ways but does not worked.
public class Teste {
public static void main(String[] args) throws ParseException {
String l = "480364794";
String d = "479617200";
print(convertEpoc("444663422"));
print(convert("480364794", "dd/MM/yyyy HH:mm:ss"));
print(convert("479617200", "dd/MM/yyyy HH:mm:ss"));
}
private static String convertEpoc(String d) {
long epoch = Long.parseLong(d);
Instant instant = Instant.ofEpochMilli(epoch * 1000);
ZonedDateTime.ofInstant(instant, ZoneOffset.UTC);
return instant.toString();
}
public static String convert(String epochSec, String dateFormatStr) {
Date date = new Date(Long.parseLong(epochSec) * 1000);
SimpleDateFormat format = new SimpleDateFormat(dateFormatStr,
Locale.getDefault());
return format.format(date);
}
public static void print(String s) {
System.out.println(s);
}}
what am i doing wrong?
Aucun commentaire:
Enregistrer un commentaire