List of utility methods to do Timestamp Create
String | timestamp2string() timestampstring return String.valueOf(System.currentTimeMillis() / 1000);
|
byte[] | timestamp4(int unixTime) http://stackoverflow.com/questions/29273498/getting-date-time-in-unix-time-as-byte-array-which-size-is-4-bytes-with-java byte[] productionDate = new byte[] { (byte) (unixTime >> 24), (byte) (unixTime >> 16), (byte) (unixTime >> 8), (byte) unixTime }; return productionDate; |
String | timestampDifference(long ts1, long ts2) timestamp Difference long difference = (ts1 - ts2) / 1000; if (difference <= 0) { return "0 second"; String strIntervals[][] = new String[][] { new String[] { "year", "years" }, new String[] { "month", "months" }, new String[] { "week", "weeks" }, new String[] { "day", "days" }, new String[] { "hour", "hours" }, new String[] { "minute", "minutes" }, new String[] { "second", "seconds" }, }; ... |
long | timestampMicros() timestamp Micros return System.currentTimeMillis() * 1000;
|
byte[] | timestampNonce(final int length) Generates a nonce of the given size by repetitively concatenating system timestamps (i.e. if (length <= 0) { throw new IllegalArgumentException(length + " is invalid. Length must be positive."); final byte[] nonce = new byte[length]; int count = 0; long timestamp; while (count < length) { timestamp = System.nanoTime(); ... |
long | timestampNow() timestamp Now return System.currentTimeMillis();
|
long | timestampStartOfDay(long time) timestamp Start Of Day Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(time);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
return cal.getTimeInMillis();
|
long | timestampStringToUnixDate(String s) timestamp String To Unix Date final long d; final long t; s = s.trim(); int space = s.indexOf(' '); if (space >= 0) { d = dateStringToUnixDate(s.substring(0, space)); t = timeStringToUnixDate(s, space + 1); } else { ... |
java.sql.Timestamp | toOracleTimestamp(String stringDate, int intFlag) given format of dd/mm/yyyy, and return Timestamp yyyy-mm-dd hh:mm:ss.000000000 java.sql.Timestamp oracleDate = null; if (stringDate == null) return null; try { oracleDate = java.sql.Timestamp.valueOf(toOracleDatetime(stringDate, intFlag)); } catch (Exception e) { return null; return oracleDate; |
java.sql.Timestamp | toSQLTime(Instant timestamp) Convert EPICS time stamp into SQL time stamp final java.sql.Timestamp sql = new java.sql.Timestamp(timestamp.toEpochMilli()); sql.setNanos(timestamp.getNano()); return sql; |