I want to convert following String value in time format .
String convertInTime="10:20 AM"
And then I want to round up to "11:00 AM "
How should I do this?
I don't know whether you can use the apache commons library, if so then please refer to: org.apache.commons.lang3.time.DateUtils.round(Date date, int field) :
The first parameter is a java.util.Date that you can create with a help of java.text.SimpleDateFormat , and the second parameter is a constant from a Calendar class like Calendar.HOUR .
If you can't employ the apache commons library check how they do it: http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/src-html/org/apache/commons/lang3/time/DateUtils.html#line.645 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.