mirror of https://github.com/readrops/Readrops.git
Migrate Converters to kotlin
This commit is contained in:
parent
4dfa474d14
commit
07e586a989
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue