Example usage for org.joda.time Minutes TWO

List of usage examples for org.joda.time Minutes TWO

Introduction

In this page you can find the example usage for org.joda.time Minutes TWO.

Prototype

Minutes TWO

To view the source code for org.joda.time Minutes TWO.

Click Source Link

Document

Constant representing two minutes.

Usage

From source file:aDeleteME.DeleteME.java

public static void main(String[] args) {
    Random random = new Random();

    DateTime startTime = new DateTime(random.nextLong()).withMillisOfSecond(0);

    Minutes minimumPeriod = Minutes.TWO;
    int minimumPeriodInSeconds = minimumPeriod.toStandardSeconds().getSeconds();
    int maximumPeriodInSeconds = Hours.ONE.toStandardSeconds().getSeconds();

    Seconds randomPeriod = Seconds.seconds(random.nextInt(maximumPeriodInSeconds - minimumPeriodInSeconds));
    DateTime endTime = startTime.plus(minimumPeriod).plus(randomPeriod);

    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");

    System.out.println(dateTimeFormatter.print(startTime));
    System.out.println(dateTimeFormatter.print(endTime));
}