Java BigInteger Calculate getDateOf(final BigInteger fileTime)

Here you can find the source of getDateOf(final BigInteger fileTime)

Description

Date values in ASF files are given in 100 ns (10 exp -4) steps since first

License

Open Source License

Parameter

Parameter Description
fileTime Time in 100ns since 1 jan 1601

Return

Calendar holding the date representation.

Declaration

public static GregorianCalendar getDateOf(final BigInteger fileTime) 

Method Source Code

//package com.java2s;
/*//from  w  ww  . j  av  a2s . c om
 * Entagged Audio Tag library
 * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *  
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

import java.math.BigInteger;

import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static final long DIFF_BETWEEN_ASF_DATE_AND_JAVA_DATE = 11644470000000l;

    /**
     * Date values in ASF files are given in 100 ns (10 exp -4) steps since first
     *
     * @param fileTime Time in 100ns since 1 jan 1601
     * @return Calendar holding the date representation.
     */
    public static GregorianCalendar getDateOf(final BigInteger fileTime) {
        final GregorianCalendar result = new GregorianCalendar();

        // Divide by 10 to convert from -4 to -3 (millisecs)
        BigInteger time = fileTime.divide(new BigInteger("10"));
        // Construct Date taking into the diff between 1601 and 1970
        Date date = new Date(time.longValue() - DIFF_BETWEEN_ASF_DATE_AND_JAVA_DATE);
        result.setTime(date);
        return result;
    }
}

Related

  1. getBytes(BigInteger big, int bitlen)
  2. getBytesWithoutSign(BigInteger arg)
  3. getClearExpPipe(BigInteger M)
  4. getCreateLocalNextHopJobKey(Long vpnId, BigInteger dpnId, String prefix)
  5. getDateOf(BigInteger fileTime)
  6. getDigitCount(BigInteger number)
  7. getHexString(BigInteger bigInt)
  8. getHistogramBigInt(List data, int breaks)
  9. getIntegral(String number, BigInteger def)