Hello i want date without time but that should be in java.utill object
output should be - 2014-08-22
Hello i want date without time but that should be in java.utill object
output should be - 2014-08-22
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
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);