Java Date to String dateToStr(Date date, String formatType)

Here you can find the source of dateToStr(Date date, String formatType)

Description

date To Str

License

Apache License

Declaration

static String dateToStr(Date date, String formatType) 

Method Source Code


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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    static String dateToStr(Date date, String formatType) {

        return longTypeToStr(date.getTime(), formatType);

    }//ww  w. j  a v a2  s .  co m

    static String longTypeToStr(long time, String formatType) {

        String strTime = "";
        if (time > 0) {
            SimpleDateFormat sDateFormat = new SimpleDateFormat(formatType);

            strTime = sDateFormat.format(new Date(time));

        }

        return strTime;

    }
}

Related

  1. dateToStr(Date date)
  2. dateToStr(Date date, int type)
  3. dateToStr(Date date, String format)
  4. dateToStr(Date date, String format)
  5. dateToStr(Date date, String formatstr)
  6. dateToStr(Date source)
  7. datetoStr2(Date date)
  8. datetoStr3(Date date)
  9. dateToStrIBInput(Date date)