Java Date to String convertDateTimeToString(Date date)

Here you can find the source of convertDateTimeToString(Date date)

Description

convert Date Time To String

License

Open Source License

Parameter

Parameter Description
date to convert

Exception

Parameter Description
Exception if error

Return

String

Declaration

public static String convertDateTimeToString(Date date) throws Exception 

Method Source Code

//package com.java2s;
/*//w w  w  .  j  a v a  2  s.  c  o  m
 * Copyright (C) 2010 dungnv. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    /**
     *
     * @param date to convert
     * @return String
     * @throws Exception if error
     */
    public static String convertDateTimeToString(Date date) throws Exception {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
        try {
            return dateFormat.format(date);
        } catch (Exception e) {
            throw e;
        }
    }
}

Related

  1. convertDate(Date passedDate)
  2. convertDate(final Date date)
  3. convertDate2Str(java.util.Date date, String format, String defaultValue)
  4. convertDate2String(Date date)
  5. convertDate2String8(Date time)
  6. convertDateTo(Date date, String patternToUse)
  7. convertDateToServerTimeZoneDate(DateFormat formatter, String timeZoneName, long milliSecond)
  8. convertDateToStr(Date d, String format)
  9. convertDateToStr(Date date, String format)