Applib-HarmonyOS / NaturalDateFormat

A library to format dates as described in Material Design guidelines.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.github/workflows/main.yml Quality Gate Status

NaturalDateFormat

A HMOS library to format dates.

Source

Inspired by ZieIony/NaturalDateFormat

Feature

This library provides feature to format dates. RelativeDateFormat formats date as relative (4 months ago, today, next year), AbsoluteDateFormat formats date as absolute (Monday, 4:32 PM, June 10). This library internally uses Joda Time "joda-time:joda-time:2.9.4".

Dependency

  1. For using naturaldateformat module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
	dependencies {
                implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
                testImplementation 'junit:junit:4.13'
                ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
                implementation project(path: ':naturaldateformat')
        }
  1. For using naturaldateformat in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
	dependencies {
                implementation fileTree(dir: 'libs', include: ['*.jar'])
                testImplementation 'junit:junit:4.13'
                compile 'joda-time:joda-time:2.9.4'
        }
  1. For using naturaldateformat from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
         dependencies {
                 implementation ('dev.applibgroup:naturaldateformat:1.0.0')  
	         testCompile 'junit:junit:4.13'
         }

Usage

Java

RelativeDateFormat relFormat = new RelativeDateFormat(context,NaturalDateFormat.DATE);
AbsoluteDateFormat absFormat = new AbsoluteDateFormat(context,NaturalDateFormat.DATE | NaturalDateFormat.HOURS | NaturalDateFormat.MINUTES);
relFormat.format(new Date().getTime());
absFormat.format(new Date().getTime());

About

A library to format dates as described in Material Design guidelines.

License:Apache License 2.0


Languages

Language:Java 100.0%