Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    /**
     * Turns a Java date object into a mySQL acceptable date string
     *
     * @param date
     *            Date object
     * @return mySQL acceptable date string
     */
    public static String toSQLDateString(Date date, String timezone) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setTimeZone(TimeZone.getTimeZone(timezone));
        return dateFormat.format(date);
    }
}