Java Date to String date2String(Date date, String pattern)

Here you can find the source of date2String(Date date, String pattern)

Description

Date --> String

License

Apache License

Parameter

Parameter Description
date Date
pattern pattern

Return

date String

Declaration

public static String date2String(Date date, String pattern) 

Method Source Code

//package com.java2s;
/*//ww  w .  ja v  a2s  .  co m
 * Copyright 2014 the original author or authors.
 *
 * 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.util.Date;

public class Main {
    /**
     * Date --> String
     *
     * @param date    Date
     * @param pattern pattern
     * @return date String
     */
    public static String date2String(Date date, String pattern) {
        java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat(pattern);
        return dateFormat.format(date);
    }
}

Related

  1. Date2String(Date date, String DateFormat)
  2. date2string(Date date, String format)
  3. date2String(Date date, String format)
  4. date2String(Date date, String format)
  5. Date2String(Date date, String formatPattern)
  6. date2String(Date source, String formatString)
  7. date2String(Date value)
  8. date2String(java.util.Date date, String format)
  9. date2String(java.util.Date date, String pattern)