Getting Date Time in Unix Time as Byte Array which size is 4 bytes with Java
问题 How Can I get the date time in unix time as byte array which should fill 4 bytes space in Java? Something like that: byte[] productionDate = new byte[] { (byte) 0xC8, (byte) 0x34, (byte) 0x94, 0x54 }; 回答1: First: Unix time is a number of seconds since 01-01-1970 00:00:00 UTC. Java's System.currentTimeMillis() returns milliseconds since 01-01-1970 00:00:00 UTC. So you will have to divide by 1000 to get Unix time: int unixTime = (int)(System.currentTimeMillis() / 1000); Then you'll have to get