Java SQL Date Get getDateOfShortStr(String dateStr)

Here you can find the source of getDateOfShortStr(String dateStr)

Description

get Date Of Short Str

License

Open Source License

Declaration

public static java.sql.Date getDateOfShortStr(String dateStr) 

Method Source Code


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

import java.util.Calendar;

public class Main {
    static final DateFormat YYYYMMDD_FORMAT = new java.text.SimpleDateFormat("yyyyMMdd");

    public static java.sql.Date getDateOfShortStr(String dateStr) {
        java.sql.Date da = null;//from  w  ww .  ja v  a  2  s . c o  m
        try {
            da = new java.sql.Date(YYYYMMDD_FORMAT.parse(dateStr).getTime());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return da;
    }

    public static String getTime() {
        Timestamp time = new Timestamp(Calendar.getInstance().getTime().getTime());
        return time.toString();
    }
}

Related

  1. getDateFromTimestamp(Timestamp timestamp)
  2. getDateFromYMD(Date ymd)
  3. getDateInput(String prompt)
  4. getDateISO(final String sDate)
  5. getDateNextMonth(java.util.Date current)
  6. getDateOfString(long time, String patten)
  7. getDateOrTime(int colType, Object o)
  8. getDateParameter(java.sql.Date date, int param)
  9. getDatePath(java.sql.Timestamp fileDate)