Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

public class Main {

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

    public static Timestamp toTimestamp(LocalDate localDate) {
        Date date = Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
        Timestamp timeStamp = new Timestamp(date.getTime());
        return timeStamp;
    }
}