Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        Date d = new Date(time);
        Timestamp t = new Timestamp(time);
        t.setNanos(123456789);
        System.out.println(d);
        System.out.println(t);
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.'");
        NumberFormat nf = new DecimalFormat("000000000");
        System.out.println(df.format(t.getTime()) + nf.format(t.getNanos()));
    }
}