Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Noda Time 1.2 Released with XML, JSON Serialization and Text Formatting

Noda Time 1.2 Released with XML, JSON Serialization and Text Formatting

This item in japanese

Noda Time 1.2 has been released with support for XML and binary serialization and text formatting in addition to an optional assembly to handle JSON serialization. It provides an ability to format and parse Duration, OffsetDateTime, and ZonedDateTime types and includes Interval.Contains(), ZonedDateTime.Calendar() methods in addition to several bug fixes.

The recent release provides support for NodaTime.Serialization.JsonNet assembly which is built using Json.NET 4.5.11 and is available for both portable and desktop platforms. Moreover, an extension method of ConfigureForNodaTime is provided on JsonSerializer, JsonSerializerSettings and NodaConverters type provides public static read-only fields for individual converters, where all of them are immutable. Alternatively, custom converters can be created easily from patterns using NodaPatternConverter.

Noda Time 1.2 has added several API changes such as introducing new classes such as DurationPattern, OffsetDateTimePattern and ZonedDateTimePattern that represent patterns for parsing and formatting Duration, OffsetDateTime, and ZonedDateTime respectively. It also introduces new properties such as GeneralIsoPattern, BclRoundtripPattern and FullRoundtripPattern which provide programmatic access to the o/O, r and s patterns. The release also sealed DateTimeZoneNotFoundException, CalendarSystem and InvalidNodaDataException.

In Noda Time 1.2, the types Instant, OffsetDateTime, ZonedDateTime, LocalDateTime, LocalDate, LocalTime, Offset, Interval, Duration, PeriodBuilder implement IXmlSerializable and can be serialized. Moreover, these type also implement ISerializable and can be serialized using BinaryFormatter by using [Serializable] attribute.

The recent release also includes InstantPattern.WithMinMaxLabels(), which provides an ability to replace text used to format the minimum and maximum instants in addition to the new Era.AnnoMartyrum which is a replacement to previously misnamed AnnoMartyrm. It also adds Interval.Contains(), ZonedDateTime.Calendar and ZonedDateTime.GetZoneInterval() methods in addition to ParseResult.Exception, which provides direct access to the exception that would be thrown by GetValueOrThrow() method.

Noda Time 1.2 has fixed a bug where Period.Between() could return a mixture of positive and negative values when called with end-of-month and near-leap-year values in addition to fixing a incorrect overflow when creating a Period that exceeded long.MaxValue ticks. The release also removed support for upper-case aliases for the existing Instant patterns n, g, and d.

Rate this Article