Java Date to String convertDate(Date passedDate)

Here you can find the source of convertDate(Date passedDate)

Description

Converts a date to a standard system-wide format

License

Apache License

Parameter

Parameter Description
passedDate java.util.Date date passed

Return

String formatted to dd/MM/yyyy

Declaration

public static String convertDate(Date passedDate) 

Method Source Code


//package com.java2s;
/*/*from w w w  .j a  va2 s.  co m*/
    
<!--
Copyright 2015 Paul Withers
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License
-->
    
*/

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

public class Main {
    /**
     * Converts a date to a standard system-wide format
     *
     * @param passedDate
     *            java.util.Date date passed
     * @return String formatted to dd/MM/yyyy
     */
    public static String convertDate(Date passedDate) {
        final SimpleDateFormat DATE_FORMAT_DATE_ONLY = new SimpleDateFormat("dd/MM/yyyy");
        return DATE_FORMAT_DATE_ONLY.format(passedDate);
    }
}

Related

  1. convert(Date date, String style)
  2. convertDate(Date d)
  3. convertDate(Date date)
  4. convertDate(Date date)
  5. convertDate(Date date)
  6. convertDate(final Date date)
  7. convertDate2Str(java.util.Date date, String format, String defaultValue)
  8. convertDate2String(Date date)
  9. convertDate2String8(Date time)