Where to download?
You can still download earlier outdated versions from Maven Central (just use the search word "Time4J").
You should choose the version line v4.x if you work on Java-8 (only) otherwise you must use the version line v3.x (for Java 6 or 7). For Java 9+, those outdated versions are not recommended and don't work if running on the module path.
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.38<version> </dependency>
Every module of Time4J has an artifactId in this form: time4j-{module-name}. Following module names are valid:
- calendar
- core
- i18n
- misc
- olson
- range
- tzdata
- ui (only v4.20 or later)
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
- The sister project Time4A manages and yields the Android version of Time4J.
- 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.40-2018b).
- Time4A is capable of observing any settings of the system timezone on mobile devices.
- Using Proguard (with "minifiyEnabled=true") will help to shrink the size of Time4A to an acceptable size.
- 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.
- 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.40-2018b' }
- Finally you should initialize your time-app as follows: Either you write an extra
Application
-class which inherits from the Time4A-classnet.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); } }
- 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: ReplaceApplicationStarter.initialize(this)
byApplicationStarter.registerReceiver(this)
.