Here you can find the source of putMillisToByteArray(byte[] buff, long value, int offset)
Parameter | Description |
---|---|
buff | the buffer to store the seconds into. |
value | the millis long value to store. |
offset | the offset at which to store the value. |
public static void putMillisToByteArray(byte[] buff, long value, int offset)
//package com.java2s; /*/* ww w .java 2s .co m*/ * $Id$ * * Copyright (c) 2008-2014 David Muller <roxon@users.sourceforge.net>. * All rights reserved. Use of the code is allowed under the * Artistic License 2.0 terms, as specified in the LICENSE file * distributed with this code, or available from * http://www.opensource.org/licenses/artistic-license-2.0.php */ public class Main { /** * Stores a long milliseconds as seconds in a byte array. The value is four * bytes in little-endian order starting at <code>offset</code>. * * @param buff the buffer to store the seconds into. * @param value the millis long value to store. * @param offset the offset at which to store the value. */ public static void putMillisToByteArray(byte[] buff, long value, int offset) { value /= 1000L; // convert from millis to seconds buff[offset + 0] = (byte) (value & 0xff); buff[offset + 1] = (byte) ((value & 0xff00) >>> 8); buff[offset + 2] = (byte) ((value & 0xff0000) >>> 16); buff[offset + 3] = (byte) ((value & 0xff000000) >>> 24); } }