// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.oer.its.ieee1609dot2.basetypes;

import org.bouncycastle.util.BigIntegers;
import org.bouncycastle.asn1.ASN1Integer;
import java.math.BigInteger;

public class Time64 extends UINT64
{
    public static long etsiEpochMicros;
    
    public Time64(final long val) {
        this(BigInteger.valueOf(val));
    }
    
    public Time64(final BigInteger bigInteger) {
        super(bigInteger);
    }
    
    public Time64(final UINT64 uint64) {
        this(uint64.getValue());
    }
    
    public static Time64 now() {
        return new Time64(1000L * System.currentTimeMillis() - Time64.etsiEpochMicros);
    }
    
    public static Time64 ofUnixMillis(final long n) {
        return new Time64(n * 1000L - Time64.etsiEpochMicros);
    }
    
    public static Time64 getInstance(final Object o) {
        if (o instanceof UINT64) {
            return new Time64((UINT64)o);
        }
        if (o != null) {
            return new Time64(ASN1Integer.getInstance(o).getValue());
        }
        return null;
    }
    
    public long toUnixMillis() {
        return (BigIntegers.longValueExact(this.getValue()) + Time64.etsiEpochMicros) / 1000L;
    }
    
    static {
        Time64.etsiEpochMicros = Time32.etsiEpochMillis * 1000L;
    }
}
