Getting Year, Month and Date in Android

前端 未结 9 1922
走了就别回头了
走了就别回头了 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:46

    I tried your code and it is giving correct output. You should try checking time in your emulator/phone on which you are trying this code.

    According to getInstance docs, it sets to current date and time by Default.

提交回复
热议问题