I would like to get the current date with zero time in milliseconds.
Example: if today is 12:69 pm, I want to get the time in milliseconds for today without time ... that is, the time immediately after midnight (one millisecond or 0 if it works).
I used the Calendar object, but I canβt figure out how to reset the time part.
Here's how to zero calendar time:
Calendar today = Calendar.getInstance(); today.set(Calendar.MILLISECOND, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.HOUR_OF_DAY, 0);
And without a calendar:
long d = new Date().getTime(); int offset = TimeZone.getDefault().getOffset(d); d = ((d + offset)/ 86400000l) * 86400000l - offset;
Source: https://habr.com/ru/post/903289/More articles:Java library for visualizing the algorithm - javaUsing the DATE field as the primary key for measuring date using MySQL - datecollection.mutable.OpenHashMap vs collection.mutable.HashMap - scalaCreate a patch from several versions of TortoiseSVN using the command line - windowscreate table constraint in mysql - sqlCannot start Android 4.0 action bar. Split Action - androidjava.lang.Exception: port 8083 is already in use - javaHow to change the structure of MongoDB maps? - mongodbHow do you get exceptions in the implementation of EventMachine? - ruby ββ| fooobar.comHow to get the exit code of a command, not xterm? - bashAll Articles