Java SQL Date Parse parseDate(String s)

Here you can find the source of parseDate(String s)

Description

parse Date

License

Open Source License

Declaration


public static Date parseDate(String s) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date parseDate(String s) {
        Calendar c = Calendar.getInstance();
        try {/*w  w  w .java 2s  . co m*/
            int d = Integer.parseInt(s);
            int year = d / 10000;
            int month = (d % 10000) / 100;
            int day = d % 100;
            c.set(year, month - 1, day);
        } catch (Exception e) {
            return null;
        }
        return c.getTime();
    }

    public static String getTime() {
        java.util.Date dt = new java.util.Date();
        java.sql.Timestamp ts = new java.sql.Timestamp(dt.getTime());
        String time = ts.toString();
        return time.substring(0, 19);
    }
}

Related

  1. parse(String date)
  2. parseDate(final String dateString)
  3. parseDate(String date)
  4. parseDate(String dateStr, String formatStr)
  5. parseDate(String exifDate)
  6. parseDate(String s)
  7. parseDate(String strDate)
  8. parseDate(String strFormat, String dateValue)
  9. parseDate(String value, String format)