Getting Year, Month and Date in Android

前端 未结 9 2101
走了就别回头了
走了就别回头了 2021-02-06 21:04

I am trying to get today\'s Year, Month and Date using following code;

Calendar calendar = Calendar.getInstance();

int thisYear = calendar.get(Calendar.YEAR);
L         


        
9条回答
  •  佛祖请我去吃肉
    2021-02-06 21:51

    Would I be correct in assuming this is running on a Emulator? If so, Set the emulator date correctly, and it should be correct.

    From memory, that code should do what you expect.

提交回复
热议问题