Skip to content

modelmapper/modelmapper-module-java8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ModelMapper Module for Java8

Build Status License Maven Central

This is a module for ModelMapper to support Java 8 features.

Java 8 Date/Time

Registers the module

modelMapper.registerModule(new Jsr310Module());

Configuration

We also support for configuration.

// using String patterns
Jsr310ModuleConfig config = Jsr310ModuleConfig.builder()
    .dateTimePattern("yyyy-MM-dd HH:mm:ss") // default is yyyy-MM-dd HH:mm:ss
    .datePattern("yyyy-MM-dd") // default is yyyy-MM-dd
    .zoneId(ZoneOffset.UTC) // default is ZoneId.systemDefault()
    .build()
modelMapper.registerModule(new Jsr310Module(config));
// using DateTimeFormatter directly
Jsr310ModuleConfig config = Jsr310ModuleConfig.builder()
    .dateTimeFormatter(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
    .dateFormatter(DateTimeFormatter.ISO_LOCAL_DATE)
    .zoneId(ZoneOffset.UTC)
    .build()
modelMapper.registerModule(new Jsr310Module(config));

Support Mappings

Source Type Destination Type
LocalDateTime String
LocalDateTime Long/long
LocalDateTime BigDecimal
LocalDateTime BigInteger
LocalDateTime Date
LocalDateTime Calendar
LocalDate String
LocalDate Long/long
LocalDate BigDecimal
LocalDate BigInteger
LocalDate Date
LocalDate Calendar
OffsetDateTime String
OffsetDateTime Long/long
OffsetDateTime BigDecimal
OffsetDateTime BigInteger
OffsetDateTime Date
OffsetDateTime Calendar
Instant String
Instant Long/long
Instant BigDecimal
Instant BigInteger
Instant Date
Instant Calendar
String LocalDateTime
Long/long LocalDateTime
BigDecimal LocalDateTime
BigInteger LocalDateTime
Date LocalDateTime
Calendar LocalDateTime
String DateTime
Long/long DateTime
BigDecimal DateTime
BigInteger DateTime
Date DateTime
Calendar DateTime
String OffsetDateTime
Long/long OffsetDateTime
BigDecimal OffsetDateTime
BigInteger OffsetDateTime
Date OffsetDateTime
Calendar OffsetDateTime
String Instant
Long/long Instant
BigDecimal Instant
BigInteger Instant
Date Instant
Calendar Instant

About

ModelMapper Module for Java8

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages