All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.razorvine.pickle.objects.Tzinfo Maven / Gradle / Ivy

Go to download

This library allows your Java program to interface very easily with the Python world. It uses the Pyro protocol to call methods on remote objects. (See https://pyro5.readthedocs.io/). Pyrolite only implements part of the client side Pyro library, hence its name 'lite'... So if you don't need Pyro's full feature set, Pyrolite may be a good choice to connect java or .NET and python. Version 5.0 changes: support Pyro5 wire protocol. Dropped support of Pyro4 (stick to version 4.xx for that).

There is a newer version: 5.1
Show newest version
package net.razorvine.pickle.objects;

import java.util.HashMap;
import java.util.TimeZone;
import net.razorvine.pickle.PickleException;

/**
 * Timezone offset class that implements __setstate__ for the unpickler
 * to track what TimeZone a dateutil.tz.tzoffset or tzutc should unpickle to
 */
public class Tzinfo {

    private boolean forceTimeZone;
    private TimeZone timeZone;

    public Tzinfo(TimeZone timeZone) {
        this.forceTimeZone = true;
        this.timeZone = timeZone;
    }

    public Tzinfo() {
        this.forceTimeZone = false;
    }

    public TimeZone getTimeZone() {
        return this.timeZone;
    }

    /**
     * called by the unpickler to restore state
     */
    public void __setstate__(HashMap args) {
        if (this.forceTimeZone)
            return;
        throw new PickleException("unexpected pickle data for tzinfo objects: can't __setstate__ with anything other than an empty dict, anything else is unimplemented");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy