Migrate Converters to kotlin

This commit is contained in:
Shinokuni 2021-09-01 22:27:05 +02:00
parent 4dfa474d14
commit 07e586a989
2 changed files with 28 additions and 31 deletions

View File

@ -1,31 +0,0 @@
package com.readrops.db;
import androidx.room.TypeConverter;
import com.readrops.db.entities.account.AccountType;
import org.joda.time.LocalDateTime;
public class Converters {
@TypeConverter
public LocalDateTime fromTimeStamp(Long value) {
return new LocalDateTime(value);
}
@TypeConverter
public long fromLocalDateTime(LocalDateTime localDateTime) {
return localDateTime.toDateTime().getMillis();
}
@TypeConverter
public AccountType fromAccountTypeCode(int ordinal) {
return AccountType.values()[ordinal];
}
@TypeConverter
public int getAccountTypeCode(AccountType accountType) {
return accountType.ordinal();
}
}

View File

@ -0,0 +1,28 @@
package com.readrops.db
import androidx.room.TypeConverter
import com.readrops.db.entities.account.AccountType
import org.joda.time.LocalDateTime
object Converters {
@TypeConverter
fun fromTimeStamp(value: Long): LocalDateTime {
return LocalDateTime(value)
}
@TypeConverter
fun fromLocalDateTime(localDateTime: LocalDateTime): Long {
return localDateTime.toDateTime().millis
}
@TypeConverter
fun fromAccountTypeCode(ordinal: Int): AccountType {
return AccountType.values()[ordinal]
}
@TypeConverter
fun getAccountTypeCode(accountType: AccountType): Int {
return accountType.ordinal
}
}