Merge remote-tracking branch 'origin/upstream'

Third-Party Import of: https://github.com/gturri/jISO8601.git

Request Document: go/android3p
For CL Reviewers: go/android3p#reviewing-a-cl
For Build Team: go/ab-third-party-imports
Bug: http://b/357896336
Original import of the code can be found at: https://googleplex-android.googlesource.com/platform/external/gturri-jISO8601/+/refs/heads/third-party-review.
Security Questionnaire: http://b/357896336#comment1
Test: m gturri_jiso8601 ; atest gturri_jiso8601-tests

Change-Id: I33ca93da123078e7dfd742dc9917afd8ae330068

[maven-release-plugin] prepare release jISO8601-0.2

Update version in order to prepare mvn deploy

Update version

Add NOTICE.txt

Add README

Add Android compatibility tests

Day parsing is clearer

Minor refactorings on the hour parsing

Minor refactorings on the date parsing

Made public API static

Add pitest to pom

Add toDate

Remove useless import

One more fix for week dates

Fix for week dates

Can parse week dates

Run every test as UTC

Though it doesn't really have an impact now, it ensures tests are reproducible,
regardless of the evolution of the tested code

Remove test on a forbidden format

YYYYMM is forbidden by the norm: with this accuracy, only YYYY-MM is legal

Remove duplication in tests

No need to set default timezone for calendar date tests

Add support for ordinal dates

Can parse times

Handle calendar dates

First commit

Change-Id: I12a7f13af429ddc925755044539f7b5a31e8a4a1
tree: 317e32624908e7c298d59a22f22172b50e6cf012
  1. android-no-reg/
  2. src/
  3. .gitignore
  4. Android.bp
  5. LICENSE
  6. LICENSE.txt
  7. METADATA
  8. MODULE_LICENSE_APACHE2
  9. NOTICE.txt
  10. OWNERS
  11. pom.xml
  12. README.md
README.md

Overview

jISO8601 is yet another library made to parse dates in Java. It may still be useful since:

  • It's trivial to use
  • It's lightweight
  • It's compatible with Android
  • It can parse any date compatible with the norm

Getting started

There are only two public methods:

import fr.turri.jiso8601.*;
...
Calendar cal = Iso8601Deserializer.toCalendar("1985-03-04");
Date date = Iso8601Deserializer.toDate("1985-03-04T12:34:56Z");

Each type of ISO8601 dates are supported (calendar, ordinal and week dates, basic and extended format) as weel as each format of hour and timezone.

Installation

Using it with maven

This package will soon be available on maven central. For now it needs to be build from source. For instance, on Ubuntu:

git clone https://github.com/gturri/jiso8601
cd jiso8601
sudo apt-get install maven
mvn install

Then, in your pom.xml, add

<dependency>
    <groupId>fr.turri</groupId>
    <artifactId>jISO8601</artifactId>
    <version>0.1</version>
</dependency>

Out of scope (for now)

Recurring time interval and Periods aren't supported. Feel free to open feature requests.