Download and installation

Table Of Contents

Where to download?
Standard installation procedures
About the module dependency tree
Special notes for Android platform

Where to download?

There are two sources where you can download Time4J: GitHub and Maven. The latest versions can be found on GitHub. Another source is Maven Central (just use the search word "Time4J").

It is strongly recommended to use the latest versions where possible. Starting with the version lines v3.x and v4.x - Time4J can be considered as stable. No backwards incompatible breaks should be expected unless any class might be marked as experimental. You should choose the version line v4.x if you work on Java-8 or later otherwise you must use the version line v3.x. As deviation, the tzdata-module uses the version number scheme "1.x-2###a" where the qualifier part 2###a is identical to the TZDB-version of IANA (example: 2016c). That module is the only module which can be used together with either v4.x or v3.x.

Standard installation procedures

Either you just drop the downloaded jar-files (one jar-file exists for every module) into your classpath, or you use Apache Maven inside your IDE with following dependency section (example):

	<dependency>
		<groupId>net.time4j<groupId>
		<artifactId>time4j-core<artifactId>
		<version>4.21<version>
	</dependency>

Every module of Time4J has an artifactId in this form: time4j-{module-name}. Following module names are valid:

About the module dependency tree

If you use Maven then it is not necessary to specify the whole tree. For example, if you need the SNTP-clock implementation of Time4J then you you can just point to the misc-module and can leave out explicit references to the parent modules i18n and core.

 {core}
 |
 +---{i18n}
 |   |
 |   +---{calendar}
 |   |
 |   +---{misc}
 |   |
 |   +---{range}
 |
 +---{olson}
 |   |
 |   +---{tzdata}

Special notes for the Android platform

  1. The sister project Time4A manages and yields the Android version of Time4J.
  2. Time4A delivers the stand-alone time4j-android-artifact as AAR-library. It completely replaces the time4j-modules core, olson, tzdata, i18n and calendar. The minimum version is v3.5. The best available timezone data are already included and indicated by an extra classifier behind the version (for example: 3.33-2017b).
  3. Time4A is capable of observing any settings of the system timezone on mobile devices.
  4. Using Proguard (with "minifiyEnabled=true") will help to shrink the size of Time4A to an acceptable size.
  5. The standard service provider infrastructure of Time4J does not work as far as the substituted modules core, olson, tzdata, i18n and calendar are concerned. Time4A instead uses assets for managing its own resources. If needed you can override those assets by just making modified copies in the assets-directory of your app.
  6. It is recommended to develop the time-apps in Android Studio. Then you just need following section within your build.gradle-file (example):
    dependencies {
        compile group: 'net.time4j', name: 'time4j-android', version: '3.33-2017b'
    }
    
    If you want to use the time4j-modules misc or range then you can simply add the maven dependencies for these two modules. All other modules of Time4J should not be declared as dependencies.
  7. Finally you should initialize your time-app as follows: Either you write an extra Application-class which inherits from the Time4J-class net.time4j.android.TimeApplication - or you manually initialize your application like this:
      public class MyApplication extends Application {
        @Override
        public void onCreate() {
          super.onCreate();
          ApplicationStarter.initialize(this, true);
        }
      }
    
  8. Historical note: The first available artifacts time4j-android older than v3.5 should not be used because they depend on the core of Time4J, require an awkward configuration and yield non-optimal performance (no aar-design, just simple jars). If you still want to use it (not recommended) then take care of following special set-up:
      android {
        packagingOptions {
            pickFirst 'META-INF/services/net.time4j.scale.LeapSecondProvider'
            exclude 'META-INF/services/net.time4j.tz.ZoneProvider'
        }
        dependencies {
          compile 'net.time4j:time4j-core:3.4'
          compile 'net.time4j:time4j-android:3.4'
        }
      }
    
    Furthermore: Replace ApplicationStarter.initialize(this) by ApplicationStarter.registerReceiver(this).