Provided with Konvert

Konvert already provides a lot of default TypeConverter:

The following tables share this legend:

  • ✔ = a TypeConverter exists and is enabled by default
  • ☑ = a TypeConverter exists but is not enabled by default
  • empty = no TypeConverter existing

Basic Types

From\To BigDecimal BigInteger Boolean Byte Char Double Float Int Long Number Short String UByte UInt ULong UShort
BigDecimal ✔ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ☑
BigInteger ✔ ✔ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ☑
Boolean ☑ ☑ ✔ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ☑
Byte ✔ ✔ ☑ ✔ ☑ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ☑ ☑ ☑ ☑
Char ☑ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ☑
Double ✔ ☑ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ✔ ☑ ✔ ☑ ☑ ☑ ☑
Float ✔ ☑ ☑ ☑ ☑ ✔ ✔ ☑ ☑ ✔ ☑ ✔ ☑ ☑ ☑ ☑
Int ✔ ✔ ☑ ☑ ☑ ✔ ✔ ✔ ✔ ✔ ☑ ✔ ☑ ☑ ☑ ☑
Long ✔ ✔ ☑ ☑ ☑ ✔ ☑ ☑ ✔ ✔ ☑ ✔ ☑ ☑ ☑ ☑
Number ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ✔ ☑ ✔ ☑ ☑ ☑ ☑
Short ✔ ✔ ☑ ☑ ☑ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ☑ ☑ ☑ ☑
String ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ☑
UByte ✔ ✔ ☑ ☑ ☑ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
UInt ✔ ✔ ☑ ☑ ☑ ✔ ✔ ☑ ✔ ✔ ☑ ✔ ☑ ✔ ✔ ☑
ULong ✔ ✔ ☑ ☑ ☑ ✔ ☑ ☑ ☑ ✔ ☑ ✔ ☑ ☑ ✔ ☑
UShort ✔ ✔ ☑ ☑ ☑ ✔ ✔ ✔ ✔ ✔ ☑ ✔ ☑ ✔ ✔ ✔

Temporal Types

From\To Date Instant LocalDate LocalDateTime LocalTime OffsetDateTime OffsetTime ZonedDateTime
Date ✔ ✔            
Instant ✔ ✔            
LocalDate     ✔          
LocalDateTime     ✔ ✔ ✔      
LocalTime         ✔      
Long (epoch ms) ☑ ☑            
Long (epoch s) ☑ ☑            
OffsetDateTime ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
OffsetTime         ✔   ✔  
String ☑ ☑ ☑ ☑ ☑ ☑ ☑ ☑
ZonedDateTime ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔
From\To Long (epoch ms) Long (epoch s) String
Date ✔ ☑ ✔
Instant ✔ ☑ ✔
LocalDate     ✔
LocalDateTime     ✔
LocalTime     ✔
OffsetDateTime ✔ ☑ ✔
OffsetTime     ✔
ZonedDateTime ✔ ☑ ✔

Enum

From\To Enum
BigDecimal ☑
BigInteger ☑
Byte ☑
Double ☑
Enum ✔
Float ☑
Int ☑
Long ☑
Number ☑
Short ☑
String ☑
UByte ☑
UInt ☑
ULong ☑
UShort ☑
From\To BigDecimal BigInteger Byte Char Double Float Int Long Number Short String UByte UInt ULong UShort
Enum ☑ ✔ ☑ ☑ ☑ ☑ ✔ ✔ ✔ ✔ ✔ ☑ ✔ ✔ ✔

The EnumToEnumConverter will fail, if the target enum does not provide all possible values as the source enum.

Iterables

From\To ArrayList Collection HashSet ImmutableCollection ImmutableList ImmutableSet Iterable LinkedHashSet List MutableCollection MutableIterable MutableList MutableSet PersistentCollection PersistentList PersistentSet Set
any iterable ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔ ✔

The values inside are also mapped, if a TypeConverter for them is enabled.

Maps

From\To HashMap ImmutableMap LinkedHashMap Map MutableMap PersistentMap
any map ✔ ✔ ✔ ✔ ✔ ✔

The key and value type parameters are also mapped, if a TypeConverter for both is enabled.

Other

ToAnyConverter

Special and simple case: target is the Any type from which all types inherit.

From\To kotlin.Any
any type ✔

SameTypeConverter

Special and simple case: source and target are exactly the same type.

From\To <T>
<T> ✔