Class ZoneInfoCompiler


  • public class ZoneInfoCompiler
    extends java.lang.Object
    Compiles IANA ZoneInfo database files into binary files for each time zone in the database. DateTimeZoneBuilder is used to construct and encode compiled data files. ZoneInfoProvider loads the encoded files and converts them back into DateTimeZone objects.

    Although this tool is similar to zic, the binary formats are not compatible. The latest IANA time zone database files may be obtained here.

    ZoneInfoCompiler is mutable and not thread-safe, although the main method may be safely invoked by multiple threads.

    Since:
    1.0
    • Constructor Detail

      • ZoneInfoCompiler

        public ZoneInfoCompiler()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Launches the ZoneInfoCompiler tool.
         Usage: java org.joda.time.tz.ZoneInfoCompiler <options> <source files>
         where possible options include:
           -src <directory>    Specify where to read source files
           -dst <directory>    Specify where to write generated files
           -verbose            Output verbosely (default false)
         
        Throws:
        java.lang.Exception
      • printUsage

        private static void printUsage()
      • getLenientISOChronology

        static Chronology getLenientISOChronology()
      • writeZoneInfoMap

        static void writeZoneInfoMap​(java.io.DataOutputStream dout,
                                     java.util.Map<java.lang.String,​DateTimeZone> zimap)
                              throws java.io.IOException
        Parameters:
        zimap - maps string ids to DateTimeZone objects.
        Throws:
        java.io.IOException
      • parseYear

        static int parseYear​(java.lang.String str,
                             int def)
      • parseMonth

        static int parseMonth​(java.lang.String str)
      • parseDayOfWeek

        static int parseDayOfWeek​(java.lang.String str)
      • parseOptional

        static java.lang.String parseOptional​(java.lang.String str)
      • parseTime

        static int parseTime​(java.lang.String str)
      • parseZoneChar

        static char parseZoneChar​(char c)
      • test

        static boolean test​(java.lang.String id,
                            DateTimeZone tz)
        Returns:
        false if error.
      • compile

        public java.util.Map<java.lang.String,​DateTimeZone> compile​(java.io.File outputDir,
                                                                          java.io.File[] sources)
                                                                   throws java.io.IOException
        Returns a map of ids to DateTimeZones.
        Parameters:
        outputDir - optional directory to write compiled data files to
        sources - optional list of source files to parse
        Throws:
        java.io.IOException
      • writeZone

        private void writeZone​(java.io.File outputDir,
                               DateTimeZoneBuilder builder,
                               DateTimeZone tz)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • parseDataFile

        public void parseDataFile​(java.io.BufferedReader in,
                                  boolean backward)
                           throws java.io.IOException
        Throws:
        java.io.IOException