Java Milliseconds putMillisToByteArray(byte[] buff, long value, int offset)

Here you can find the source of putMillisToByteArray(byte[] buff, long value, int offset)

Description

Stores a long milliseconds as seconds in a byte array.

License

Open Source License

Parameter

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.

Declaration

public static void putMillisToByteArray(byte[] buff, long value, int offset) 

Method Source Code

//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);

    }
}

Related

  1. multiplyRelativeTimeMillis(long duration, long multiplier)
  2. nowMillis()
  3. OLEDateToMillis(double dSerialDate)
  4. parseDate(long milliseconds)
  5. printTimeFromMilliseconds(long milliseconds)
  6. readableTransferRate(long size, long millis)
  7. relTimestrMillis(long time)
  8. resetHourMinSecMill(final Date date)
  9. resetMilliseconds(long msec)