Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.sql.Timestamp;
import java.util.Date;

public class Main {
    public static Date getRandomDate() {
        final long beginTime = Timestamp.valueOf("2017-01-13 00:00:00").getTime();
        final long endTime = Timestamp.valueOf("2017-02-14 00:58:00").getTime();
        long diff = endTime - beginTime + 1;

        long timeStamp = beginTime + (long) (Math.random() * diff);
        return new Date(timeStamp);
    }
}