Saving and retrieving date in Firebase

后端 未结 5 1350
失恋的感觉
失恋的感觉 2020-12-09 04:12

I have a model with the following structure

public class OfferModel {
    private String mImageUrl;
    private String mOfferCode;
    private String mOffe         


        
5条回答
  •  难免孤独
    2020-12-09 04:42

    You can store the date as an epoch date. It's a long that you can get using your system time System.currentTimeMillis(); or by using the Firebase server time with their ServerValue.TIMESTAMP. The thing with the first option is that it changes with timezones and system settings. So if you store the date as a long, you just have to change your OfferModel field mStartDate to a long and then use new Date(long) to get the corresponding Date when retrieving the object.

提交回复
热议问题