Java Integer to intToTime(int time)

Here you can find the source of intToTime(int time)

Description

Convert an int value to a timecode byte that can be used in sending a seekTimecode command.

License

LGPL

Parameter

Parameter Description
time An integer value representing time (hour, minute, second, or frame)

Return

The byte representiation of that time as a value recognized by a VCR.

Declaration

public static byte intToTime(int time) 

Method Source Code

//package com.java2s;
/*/*  w w  w. j ava 2  s .c  o m*/
 * @(#)VCRUtil.java   2009.02.24 at 09:44:49 PST
 *
 * Copyright 2007 MBARI
 *
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 2.1
 * (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.gnu.org/copyleft/lesser.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Convert an <i>int</i> value to a timecode byte that can be used in sending a seekTimecode command.
     * @param time An integer value representing time (hour, minute, second, or frame)
     * @return The byte representiation of that time as a value recognized by a VCR.
     * @see org.mbari.vcr.VCRCommand
     */
    public static byte intToTime(int time) {
        double timeD = (double) time;
        int tens = (int) Math.floor(timeD / 10D) * 10;
        int ones = time - tens;

        return (byte) (((tens / 10) << 4) + ones);
    }
}

Related

  1. intToShort(final int value)
  2. intToSlider(final int min, final int max, final int value)
  3. intToSortableBytes(int value, byte[] result, int offset)
  4. intToStringBuffer(final int param, final int len)
  5. intToStringWithZeroFill(int intValue, int width)
  6. intToTime(int value)
  7. intToTriplePlace(int i)
  8. intToTwoByte(int value, byte[] destination, int offset)
  9. intToTwoBytes(int value)