Java Fraction Format formatOLETime(double oleTime)

Here you can find the source of formatOLETime(double oleTime)

Description

format OLE Time

License

Open Source License

Declaration

public static String formatOLETime(double oleTime) 

Method Source Code


//package com.java2s;
/*/*from  w w w .ja  va  2  s  .c  o  m*/
 * #%L
 * dzplugin
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2014 juxeii
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    private static final int DAYS_SINCE_UTC_EPOCH = 25569;
    private static SimpleDateFormat simpleUTCormat;

    public static String formatOLETime(double oleTime) {
        long dateTime = getMillisFromOLEDate(oleTime);
        return formatDateTime(dateTime);
    }

    public static long getMillisFromOLEDate(double oleDate) {
        Date date = new Date();
        date.setTime((long) ((oleDate - DAYS_SINCE_UTC_EPOCH) * 24 * 3600 * 1000));
        return date.getTime();
    }

    public static String formatDateTime(long dateTime) {
        return simpleUTCormat.format(new Date(dateTime));
    }
}

Related

  1. formatNumber(String number, int maxFractionalDigits)
  2. formatNumberAttribute(double v)
  3. formatNumFraction(float num, int unit)
  4. formatNumValueWithComma(double val)
  5. formatoDecimal(String tipo, double valor)
  6. formatOneDecimal(double dNumber)
  7. formatOneDp(double inNumber)
  8. formatPair(double in, double out)
  9. formatPotencia(float potencia)