, .
15 .
, :
long l = System.currentTimeMillis();
l -= l % (15*60*1000);
System.out.println(new Date(System.currentTimeMillis()));
System.out.println(new Date(l));
03 09:35:56 CET 2017
03 09:30:00 CET 2017
15*60*1000 - 15
, 15minute .
:
long r = l % (15*60*1000);
l -= r;
And check the number of minutes (depends on the accuracy you really want.
if( r / 60_000 >= 8)
l += 15*60*1000;
This will be rounded if a quarter has passed since 8 minutes (if it really means anything in English;))
Full code:
long l = System.currentTimeMillis();
long r = l % (15*60*1000);
l -= r;
if( r / 60_000 >= 8)
l += 15*60*1000;
source
share