Here you can find the source of getDateOf(BigInteger fileTime)
Parameter | Description |
---|---|
fileTime | Time in 100ns since 1 jan 1601 |
public static GregorianCalendar getDateOf(BigInteger fileTime)
//package com.java2s; /*/*from w w w. j av a 2 s . com*/ * 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.Calendar; import java.util.GregorianCalendar; public class Main { /** * Since date values in asf files are given in 100 ns steps since first * january of 1601 a little conversion must be done. <br> * This method converts a date given in described manner to a calendar. * * @param fileTime Time in 100ns since 1 jan 1601 * @return Calendar holding the date representation. */ public static GregorianCalendar getDateOf(BigInteger fileTime) { GregorianCalendar result = new GregorianCalendar(1601, 0, 1); // lose anything beyond milliseconds, because calendar can't handle // less value fileTime = fileTime.divide(new BigInteger("10000")); //$NON-NLS-1$ BigInteger maxInt = new BigInteger(String.valueOf(Integer.MAX_VALUE)); while (fileTime.compareTo(maxInt) > 0) { result.add(Calendar.MILLISECOND, Integer.MAX_VALUE); fileTime = fileTime.subtract(maxInt); } result.add(Calendar.MILLISECOND, fileTime.intValue()); return result; } }