List of utility methods to do Unix time
Date | getUnixEpochDateTime() Returns the starting Unix Epoch Time. Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); calendar.set(1970, 0, 1, 0, 0, 0); return calendar.getTime(); |
long | getUnixTime(Date date) get Unix Time Calendar instance = Calendar.getInstance(); instance.setTime(date); long utc = Date.UTC(instance.get(Calendar.YEAR) - 1900, instance.get(Calendar.MONTH), instance.get(Calendar.DAY_OF_MONTH), instance.get(Calendar.HOUR_OF_DAY), instance.get(Calendar.MINUTE), instance.get(Calendar.SECOND)); return utc; |
int | getUnixTimeByDate(Date date) get Unix Time By Date return (int) (date.getTime() / 1000L); |
int | unix2afpTime(long ut) unixafp Time int ret = (int) ((ut - timeOffset) / 1000); return ret; |
String | unixDateToString(int date) Helper for CAST({date} AS VARCHAR(n)). final StringBuilder buf = new StringBuilder(10); unixDateToString(buf, date); return buf.toString(); |
int | unixTime() unix Time return (int) (System.currentTimeMillis() / 1000); |
long | unixtime() Calculates "unix time", ie seconds after 1970 return System.currentTimeMillis() / 1000L;
|
long | unixTimestamp(int year, int month, int day, int hour, int minute, int second) unix Timestamp final int date = ymdToUnixDate(year, month, day); return (long) date * MILLIS_PER_DAY + (long) hour * MILLIS_PER_HOUR + (long) minute * MILLIS_PER_MINUTE + (long) second * MILLIS_PER_SECOND; |
String | unixTimestampToString(long timestamp) Helper for CAST({timestamp} AS VARCHAR(n)). final StringBuilder buf = new StringBuilder(17); int date = (int) (timestamp / MILLIS_PER_DAY); int time = (int) (timestamp % MILLIS_PER_DAY); if (time < 0) { --date; time += MILLIS_PER_DAY; unixDateToString(buf, date); ... |
Date | unixtimeToDate(long time) Converts a unix time stamp to a Date
Calendar c = Calendar.getInstance();
c.setTimeInMillis(time * 1000);
return c.getTime();
|