java algorithm Artery Time rounding up and down

Table of Contents ⇒ Java Algorithm Library-Artery-Sample

package jp.avaj.lib.algo;

import java.util.Calendar;

import jp.avaj.lib.test.L;

/**
 *Round up and down the time
 *
 *・ Date,Calendar,For long you can
 *・ Today's 0:00 and tomorrow's 0:00.
 *・ Truncate minutes / seconds, round up minutes / seconds
 *
 */
public class Q05_01 {
  public static void main(String[] args) {

    L.p("Today at 0:00");
    {
      Calendar cal = ArDateUtil.getCalendar();
      L.p(ArDateUtil.toString(cal));

      cal = ArDateUtil.downTo0H0M0S(cal);
      L.p(ArDateUtil.toString(cal));
    }

    L.p("Tomorrow at 0:00");
    {
      Calendar cal = ArDateUtil.getCalendar();
      L.p(ArDateUtil.toString(cal));

      cal = ArDateUtil.upTo0H0M0S(cal);
      L.p(ArDateUtil.toString(cal));
    }

    L.p("Truncate minutes and seconds");
    {
      Calendar cal = ArDateUtil.getCalendar();
      L.p(ArDateUtil.toString(cal));

      cal = ArDateUtil.downTo0M0S(cal);
      L.p(ArDateUtil.toString(cal));
    }

    L.p("Round up minutes and seconds");
    {
      Calendar cal = ArDateUtil.getCalendar();
      L.p(ArDateUtil.toString(cal));

      cal = ArDateUtil.upTo0M0S(cal);
      L.p(ArDateUtil.toString(cal));
    }
  }
}

The result is as follows.

result.txt


Today at 0:00
2019/10/10 14:09:47
2019/10/10 00:00:00
Tomorrow at 0:00
2019/10/10 14:09:47
2019/10/11 00:00:00
Truncate minutes and seconds
2019/10/10 14:09:47
2019/10/10 14:00:00
Round up minutes and seconds
2019/10/10 14:09:47
2019/10/10 15:00:00

Recommended Posts

java algorithm Artery Time rounding up and down
[MySQL] [java] Receive date and time
Java hang up?
Date and time
Java Algorithm Library-Artery-Sample
Java and JavaScript
XXE and Java
Learn for the first time java # 3 expressions and operators
Extension to add up / down button and finish button to UIToolBar
Why we gave up Java serverless and adopted Typescript