-2

Hello i want date without time but that should be in java.utill object

output should be - 2014-08-22

user3086954
  • 11
  • 1
  • 5
  • 1
    What you try till now boss. Can you put some code what u tried? – Janny Sep 18 '14 at 10:30
  • possible duplicate of [Get only the date from the timestamp](http://stackoverflow.com/questions/11421527/get-only-the-date-from-the-timestamp) – Basil Bourque Sep 19 '14 at 07:28

2 Answers2

1

java.util.Date holds internally the date/time as a long (milliseconds since January 1, 1970, 00:00:00 GMT). What you see when you are doing

Systeme.err.println(new Date());

is the result of the toString() method of Date class.

For further formatting read the doc: http://developer.android.com/reference/java/text/SimpleDateFormat.html

PeterMmm
  • 24,152
  • 13
  • 73
  • 111
0
Date date = new Date();
    int day = date.getDate();
    String Day;
    int month = date.getMonth() + 1;
    String Month;
    int year = date.getYear() + 1900;
    String Year = Integer.toString(year);
    if (day < 10) {
        Day = "0" + Integer.toString(day);
    } else {
        Day = Integer.toString(day);
    }
    if (month < 10) {
        Month = "0" + Integer.toString(month);
    } else {
        Month = Integer.toString(month);
    }
    String dates = Year + "-" + Month + "-" + Day;
    System.out.println(dates);
Karim
  • 97
  • 1
  • 9