Java Time Format getFormatDate(String timeString, String format)

Here you can find the source of getFormatDate(String timeString, String format)

Description

get Format Date

License

Open Source License

Declaration

public static String getFormatDate(String timeString, String format) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String getFormatDate(String timeString, String format) {
        long timeLong = 0L;
        if (timeString == null || timeString.length() == 0) {
            timeLong = (new Date()).getTime();
        } else {/*from ww w.  j  ava 2  s.  c  o m*/
            timeLong = Long.valueOf(timeString).longValue();
        }

        Date date = new Date();
        date.setTime(timeLong);

        SimpleDateFormat simpledateformat = new SimpleDateFormat(format);

        return simpledateformat.format(date);
    }
}

Related

  1. getDefaultDatetimeFormat()
  2. getDefaultPropertyPageDateTimeFormat()
  3. getEndDate(String time, SimpleDateFormat dateFormat)
  4. getFormat2TimetagStr()
  5. getFormatDate(Date date, boolean ShowTimePart_in)
  6. getFormatDatetime()
  7. getFormatDateTime(Date date)
  8. getFormatDateTime(Date date, String format)
  9. getFormatDateTime(java.util.Date date)