20 package org.sleuthkit.datamodel;
22 import java.text.SimpleDateFormat;
23 import java.util.Date;
24 import java.util.TimeZone;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
33 private static final Logger LOGGER = Logger.getLogger(
TimeUtilities.class.getName());
34 private static final SimpleDateFormat DATE_FORMATTER =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
47 String time =
"0000-00-00 00:00:00";
49 time =
new java.text.SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z").format(
new java.util.Date(epoch * 1000));
63 public static String
epochToTime(
long epoch, TimeZone tzone) {
64 String time =
"0000-00-00 00:00:00";
66 synchronized (DATE_FORMATTER) {
67 DATE_FORMATTER.setTimeZone(tzone);
68 time = DATE_FORMATTER.format(
new java.util.Date(epoch * 1000));
83 SimpleDateFormat formatter =
new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss'Z'");
84 formatter.setTimeZone(tzone);
85 return formatter.format(
new Date(epoch));
98 epoch =
new java.text.SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss").parse(time).getTime() / 1000;
99 }
catch (Exception e) {
100 LOGGER.log(Level.WARNING,
"Failed to parse time string", e);
static long timeToEpoch(String time)
static String epochToTime(long epoch)
static String epochToTimeISO8601(long epoch, TimeZone tzone)
static String epochToTime(long epoch, TimeZone tzone)