StephenOTT / STIX-Java

STIX 2.x Java Library
MIT License
27 stars 13 forks source link

Add Optional Sub Second precision Date/Instant Support #94

Closed StephenOTT closed 5 years ago

StephenOTT commented 5 years ago

Adds support for zero to 9 digits of sub-second precision on dates.

STIX-Java supports zero to 9 digit nanosecond precision with any date that is parsed by STIX-Java. This means that while a date that was sourced/generated by the STIX-Java library will be at sub-second precision of 3 digits, if you are parsing JSON with greater precision, or you supply a custom Instant with greater precision for a specific field, STIX-Java will support this and store the extra precision.

General rules to understand:

  1. By default, timestamps generated natively by the STIX-Java library will be be with 3 digits of sub-second prevision (millisecond precision).
  2. Sub-second precision of from 0 to 9 digits (9 digits its nano second precision: hh:mm:ss.999999999) is supported. This means you can omit sub-seconds if you choose.
  3. use the static StixDataFormats.getStixDateTimeFormatter() method for retrieving the STIX formatter, whenever you want to manually handle dates.
  4. Json parsing of JSON strings will support all of the above rules.

Fixes #93

StephenOTT commented 5 years ago

@anlklsim this has been merged, and should solve your issues. :shipit: