Android Date Today Get getTodayDateString()

Here you can find the source of getTodayDateString()

Description

get Today Date String

License

Open Source License

Declaration

public static String getTodayDateString() 

Method Source Code

//package com.java2s;
import java.util.Calendar;

public class Main {
    public static String getTodayDateString() {
        Calendar now = Calendar.getInstance();
        int year = now.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);

        String monthStr = String.valueOf(month);
        String dayStr = String.valueOf(day);

        if (month < 10) {
            monthStr = "0" + dayStr;
        }/*from  www  .ja  v a 2  s  .  co  m*/
        if (day < 10) {
            dayStr = "0" + dayStr;
        }

        String nowDate = year + "-" + monthStr + "-" + dayStr;
        return nowDate;
    }
}

Related

  1. getDateToday()
  2. getSystemDate()
  3. getToday()
  4. getTodayEndTime()
  5. getTodayStartTime()
  6. today()
  7. todayWithHour()