Java SQL Date Create getDateString(String pattern)

Here you can find the source of getDateString(String pattern)

Description

get Date String

License

Apache License

Declaration

public static String getDateString(String pattern) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;
import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String getDateString(String pattern) {
        Timestamp time = getSysDate();
        DateFormat dfmt = new SimpleDateFormat(pattern);
        java.util.Date date = time;
        return dfmt.format(date);
    }/*from   w w w.  j ava 2s.co m*/

    public static String getDateString(Timestamp time, String pattern) {
        DateFormat dfmt = new SimpleDateFormat(pattern);
        java.util.Date date = time;
        return date != null ? dfmt.format(date) : "";
    }

    public static String getDateString(Date date, String pattern) {
        SimpleDateFormat sdfmt = new SimpleDateFormat(pattern);
        return date != null ? sdfmt.format(date) : "";
    }

    public static Timestamp getSysDate() {
        return new Timestamp(System.currentTimeMillis());
    }
}

Related

  1. getDateAfter(Date date, long offset)
  2. getDateAsString(int month, int date, int year)
  3. getDateFormat()
  4. getDateFormat(java.util.Date date)
  5. getDateString(String date)
  6. getDateString2()
  7. getDay(Date date)
  8. getDay(final java.sql.Date date)
  9. getDay(String stringDate)