Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.text.DateFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static int dateToInt(Date date) {
        String str = dateToIntString(date);
        return new Integer(str);
    }

    public static int dateToInt() {
        return dateToInt(new Date());
    }

    /**
     * yyyyMMdd
     * 
     * @param date
     * @return
     */
    public static String dateToIntString(Date date) {
        DateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
        return dateformat.format(date);
    }
}