convert Date to a quarter of an hour type JAVA -
this question has answer here:
- java date rounding 6 answers
i looking way convert datatype date [java]
to quarter of hour format,
2010-08-15 12:05:15 2010-08-15 12:00:00
are there ready go methods in java already?
how this?
any hints/suggestions?
up release version 7, java comes terrible date , time api. many developers therefore choose use joda time instead. common third-party dependency in many projects.
using joda time, can following:
date toquaterofhour(date date) { localdatetime ldt = new localdatetime(date.gettime()); int quater = ldt.getminuteofhour() / 15; return ldt.withminuteofhour(quater * 15).todate(); }
java 8 comes date , time api similar of joda time.
Comments
Post a Comment