Skip to content

Instantly share code, notes, and snippets.

@ankitdubey021
Last active July 16, 2019 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitdubey021/1b6c58e1e3f1753b96b3c769ff3e9d5e to your computer and use it in GitHub Desktop.
Save ankitdubey021/1b6c58e1e3f1753b96b3c769ff3e9d5e to your computer and use it in GitHub Desktop.
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