Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    /**
     * 
     * @param object
     * @return
     */
    protected static Byte toByte(Object object) {
        String str = toString(object);
        if ("".equals(str))
            return 0;
        else
            return Byte.parseByte(str);
    }

    /**
     * 
     * @param object
     * @return
     */
    protected static String toString(Object object) {
        if (object == null) {
            return "";
        } else if (object instanceof Date) {
            return df.format(object);
        } else if (object instanceof Timestamp) {
            System.out.println("------" + df.format(object));
            return df.format(object);
        } else
            return object.toString();
    }
}