Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.Clock;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class Main {

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

    public static String getCurrentTimeStamp() {
        Clock clock = Clock.system(ZoneId.of("Europe/Berlin"));
        ZonedDateTime now = ZonedDateTime.now(clock);
        return DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(now);
    }
}