# NaturalDateFormat **Repository Path**: applibgroup/NaturalDateFormat ## Basic Information - **Project Name**: NaturalDateFormat - **Description**: A library to format dates as described in Material Design guidelines - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-16 - **Last Updated**: 2022-01-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![.github/workflows/main.yml](https://github.com/applibgroup/NaturalDateFormat/actions/workflows/main.yml/badge.svg)](https://github.com/applibgroup/NaturalDateFormat/actions/workflows/main.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=applibgroup_NaturalDateFormat&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=applibgroup_NaturalDateFormat) # NaturalDateFormat A HMOS library to format dates. ## Source Inspired by [ZieIony/NaturalDateFormat](https://github.com/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". ![](screenshots/NaturalDateFormat.png) ## 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. ```groovy 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') } ``` 2. 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. ```groovy dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.13' compile 'joda-time:joda-time:2.9.4' } ``` 3. For using naturaldateformat from a remote repository in separate application, add the below dependencies in entry/build.gradle file. ``` groovy dependencies { implementation ('dev.applibgroup:naturaldateformat:1.0.0') testCompile 'junit:junit:4.13' } ``` ## Usage #### Java ```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()); ```