Java Timestamp Create timestamp4(int unixTime)

Here you can find the source of timestamp4(int unixTime)

Description

http://stackoverflow.com/questions/29273498/getting-date-time-in-unix-time-as-byte-array-which-size-is-4-bytes-with-java

License

Open Source License

Declaration

public static byte[] timestamp4(int unixTime) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w w  w.  j a v a2 s.  co  m
     * http://stackoverflow.com/questions/29273498/getting-date-time-in-unix-time-as-byte-array-which-size-is-4-bytes-with-java
     * @return
     */
    public static byte[] timestamp4(int unixTime) {
        byte[] productionDate = new byte[] { (byte) (unixTime >> 24), (byte) (unixTime >> 16),
                (byte) (unixTime >> 8), (byte) unixTime };
        return productionDate;
    }

    public static byte[] timestamp4() {
        return timestamp4((int) (System.currentTimeMillis() / 1000));
    }
}

Related

  1. getTimestampXDaysFromY(long startTimeInMillis, int daysFromStartDate)
  2. getTimeStrByTimestamp(long timestamp, String tz)
  3. timestamp()
  4. timeStamp()
  5. timestamp2string()
  6. timestampDifference(long ts1, long ts2)
  7. timestampMicros()
  8. timestampNonce(final int length)
  9. timestampNow()