Skip to content

Instantly share code, notes, and snippets.

@ankitdubey021
Last active July 16, 2019 10:09
Embed
What would you like to do?
package dao;
import java.util.Date;
import androidx.room.TypeConverter;
public class DateConverter {
@TypeConverter
public static Date toDate(Long timestamp){
if(timestamp!=null){
return new Date(timestamp);
}
return null;
}
@TypeConverter
public static Long toTimeStamp(Date date){
if(date!=null){
return date.getTime();
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment