Java Timestamp Format format(Date aTs_Datetime)

Here you can find the source of format(Date aTs_Datetime)

Description

format

License

Apache License

Declaration

public static String format(Date aTs_Datetime) 

Method Source Code


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

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String DATE_PATTERN_DEFAULT = "yyyy-MM-dd";

    public static String format(Date aTs_Datetime) {
        return format(aTs_Datetime, DATE_PATTERN_DEFAULT);
    }/*from w ww.jav  a2 s. c  om*/

    public static String format(Date aTs_Datetime, String as_Pattern) {
        if (aTs_Datetime == null || as_Pattern == null)
            return null;
        SimpleDateFormat dateFromat = new SimpleDateFormat();
        dateFromat.applyPattern(as_Pattern);

        return dateFromat.format(aTs_Datetime);
    }

    /**
     * @param aTs_Datetime
     * @param as_Pattern
     * @return
     */
    public static String format(Timestamp aTs_Datetime, String as_Pattern) {
        if (aTs_Datetime == null || as_Pattern == null)
            return null;
        SimpleDateFormat dateFromat = new SimpleDateFormat();
        dateFromat.applyPattern(as_Pattern);

        return dateFromat.format(aTs_Datetime);
    }
}

Related

  1. compareTimstampStr(String timestamp1, String timestamp2, String format)
  2. decodeFileTimestamp(File file, Pattern filenamePattern, DateFormat dateFormat)
  3. format(BigDecimal data)
  4. format(Date date)
  5. format(Date date, String format)
  6. format(Date time, String pattern)
  7. format(Date timestamp)