Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {
    private static int offset;
    private static long firstCall = System.currentTimeMillis();

    public static void main(String[] args) {
        System.out.println(currentTime());
        System.out.println(currentTime());
        System.out.println(currentTime());
        System.out.println(currentTime());
        System.out.println(currentTime());
        System.out.println(currentTime());
    }

    public static String currentTime() {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(firstCall + (offset * 1000 * 60));
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        offset++;
        return sdf.format(cal.getTime());
    }
}