Android Date Today Get getDate()

Here you can find the source of getDate()

Description

get Date

Declaration

public static String getDate() 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    public static String getDate() {
        SimpleDateFormat fromat = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.get(Calendar.YEAR);/*w  w  w  . ja  va2  s .  c  om*/
        c.get(Calendar.MONTH + 1);
        c.get(Calendar.DAY_OF_MONTH);
        String time = fromat.format(c.getInstance().getTime());
        return time;
    }

    private static String format(int x) {
        String s = "" + x;
        if (s.length() == 1)
            s = "0" + s;
        return s;
    }
}

Related

  1. getTodayDateString()
  2. getTodayEndTime()
  3. getTodayStartTime()
  4. today()
  5. todayWithHour()
  6. getCurrentDate()
  7. getNowDate()