-1

I had question: long timeInMillis = 1488943098615; //-> Wed Mar 08 2017 10:18:18

How to switch from 1488943098615 (wed mar 08 2017 10:18:18) -> ? (timeInMillis) (wed mar 08 2017 00:00:00). That means taking all the time of the day. Eliminating hours and minutes.

Duong.Nguyen
  • 373
  • 3
  • 13
  • oh No. http://stackoverflow.com/questions/454315/how-do-you-format-date-and-time-in-android return the date i want to gettimeInMillis – Duong.Nguyen Mar 08 '17 at 03:51

2 Answers2

0
Calendar cal = Calendar.getInstance(); // defaults to currentTimeInMs
//cal.setTimeInMillis(myCurrentTime); //if you have a timestamp already
cal.set(Calendar.HOUR_OF_DAY, 0); //reset just the hour and minute parts
cal.set(Calendar.MINUTE, 0);      //leaving the same date
long msAtMidnight = cal.getTimeInMillis();
Nick Cardoso
  • 20,807
  • 14
  • 73
  • 124
0

You get current date then you sub () current date with hours = 0, minutes = 0, second = 0

Vitual code

Date currentDate = miliSecond (yyyyMMddHHmmss)
Date currentStartDate = miliSecond(yyyyMMdd000000)
miliSecondSub = currentDate - currentStartDate;
Date now = Date(miliSecondSub)
Nam Hoang
  • 46
  • 3