how do i set custom date in android

后端 未结 3 2003
无人共我
无人共我 2021-01-20 20:19

How do i set the date to 25 -12(december)- current year. eg.

I am using this code

public static Calendar defaultCalendar() {
    Calendar currentDate         


        
3条回答
  •  天命终不由人
    2021-01-20 20:41

    Use this it found very usefull to me though :

    Take a look at SimpleDateFormat.

    The basics for getting the current time in ISO8601 format:

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");
    String now = df.format(new Date());
    

    For other formats:

    DateFormat df = new SimpleDateFormat("MMM d, yyyy");
        String now = df.format(new Date());
    

    or

    DateFormat df = new SimpleDateFormat("MM/dd/yy");
    String now = df.format(new Date());
    

    EDit:

    Check this link it will help you :

    Specific date

提交回复
热议问题