BSON codecs JSR-310

BSON codecs for Java 8 Date and Time API (JSR-310).

Лицензия

Лицензия

Группа

Группа

io.github.cbartosiak
Идентификатор

Идентификатор

bson-codecs-jsr310
Последняя версия

Последняя версия

3.5.4
Дата

Дата

Тип

Тип

jar
Описание

Описание

BSON codecs JSR-310
BSON codecs for Java 8 Date and Time API (JSR-310).
Ссылка на сайт

Ссылка на сайт

https://github.com/cbartosiak/bson-codecs-jsr310
Система контроля версий

Система контроля версий

https://github.com/cbartosiak/bson-codecs-jsr310

Скачать bson-codecs-jsr310

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.cbartosiak/bson-codecs-jsr310/ -->
<dependency>
    <groupId>io.github.cbartosiak</groupId>
    <artifactId>bson-codecs-jsr310</artifactId>
    <version>3.5.4</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.cbartosiak/bson-codecs-jsr310/
implementation 'io.github.cbartosiak:bson-codecs-jsr310:3.5.4'
// https://jarcasting.com/artifacts/io.github.cbartosiak/bson-codecs-jsr310/
implementation ("io.github.cbartosiak:bson-codecs-jsr310:3.5.4")
'io.github.cbartosiak:bson-codecs-jsr310:jar:3.5.4'
<dependency org="io.github.cbartosiak" name="bson-codecs-jsr310" rev="3.5.4">
  <artifact name="bson-codecs-jsr310" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.cbartosiak', module='bson-codecs-jsr310', version='3.5.4')
)
libraryDependencies += "io.github.cbartosiak" % "bson-codecs-jsr310" % "3.5.4"
[io.github.cbartosiak/bson-codecs-jsr310 "3.5.4"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.mongodb : bson jar 3.11.0

test (2)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-api jar 5.5.1
org.junit.jupiter : junit-jupiter-engine jar 5.5.1

Модули Проекта

Данный проект не имеет модулей.

BSON codecs for Java 8 Date and Time API (JSR-310)

Build Status Maven Central Javadocs

The library provides codecs for the following JSR-310 classes:

  • java.time.DayOfWeek
  • java.time.Duration
  • java.time.Instant
  • java.time.LocalDate
  • java.time.LocalDateTime
  • java.time.LocalTime
  • java.time.Month
  • java.time.MonthDay
  • java.time.OffsetDateTime
  • java.time.OffsetTime
  • java.time.Period
  • java.time.Year
  • java.time.YearMonth
  • java.time.ZonedDateTime
  • java.time.ZoneId
  • java.time.ZoneOffset

Usage

In order to utilize the codecs one can use CodecRegistries helper, for example in case of Mongo synchronous client:

MongoClient mongoClient = MongoClients.create();
CodecRegistry codecRegistry = CodecRegistries.fromRegistries(
        MongoClientSettings.getDefaultCodecRegistry(),
        CodecRegistries.fromCodecs(new DurationAsDecimal128Codec())
);
MongoDatabase database = client
        .getDatabase(...)
        .withCodecRegistry(codecRegistry);

Note that depending on a context a different set of codecs might be necessary. There are three main factors to consider when choosing codecs:

  • queryability - how much stored values are capable of being searched;
  • sortability - how much stored values are capable of being ordered;
  • readability - how much stored values are readable for human.

The table below presents the recommendations for all the factors. The more + signs a cell contains the better a row codec is in terms of a column factor:

Codec Queryability Sortability Readability
DayOfWeekAsInt32Codec ++ ++ +
DayOfWeekAsStringCodec + ++
DurationAsDecimal128Codec + ++
DurationAsDocumentCodec ++ + +
DurationAsStringCodec ++
InstantAsDateTimeCodec + ++ +
InstantAsDocumentCodec ++ + +
InstantAsStringCodec ++
LocalDateAsDateTimeCodec + ++ +
LocalDateAsDocumentCodec ++ + +
LocalDateAsStringCodec ++
LocalDateTimeAsDateTimeCodec + ++ +
LocalDateTimeAsDocumentCodec ++ + +
LocalDateTimeAsStringCodec ++
LocalTimeAsDateTimeCodec + ++ +
LocalTimeAsDocumentCodec ++ + +
LocalTimeAsInt64Codec ++ ++
LocalTimeAsStringCodec ++
MonthAsInt32Codec ++ ++ +
MonthAsStringCodec + ++
MonthDayAsDecimal128Codec + ++ ++
MonthDayAsDocumentCodec ++ + +
MonthDayAsStringCodec ++
OffsetDateTimeAsDocumentCodec ++ + +
OffsetDateTimeAsStringCodec ++
OffsetTimeAsDocumentCodec ++ + +
OffsetTimeAsStringCodec ++
PeriodAsDocumentCodec + +
PeriodAsStringCodec ++
YearAsInt32Codec ++ ++ ++
YearMonthAsDecimal128Codec + ++ ++
YearMonthAsDocumentCodec ++ + +
YearMonthAsStringCodec ++
ZonedDateTimeAsDocumentCodec ++ + +
ZonedDateTimeAsStringCodec ++
ZoneIdAsStringCodec + ++
ZoneOffsetAsInt32Codec ++ ++
ZoneOffsetAsStringCodec + ++

Версии библиотеки

Версия
3.5.4
3.4.0
3.3.0
3.2.0
3.1.3
3.1.2
3.1.1
3.1.0
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
2.0.1
2.0.0
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.1.0
1.0.3
1.0.2
1.0.1
1.0.0