Java Date to String convertDateToURLFormat(final String dateToBeConvert)

Here you can find the source of convertDateToURLFormat(final String dateToBeConvert)

Description

convert Date To URL Format

License

Mozilla Public License

Declaration

public static String convertDateToURLFormat(final String dateToBeConvert) 

Method Source Code

//package com.java2s;
/**//  ww w.j a va  2  s.  c  o  m
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Locale;

public class Main {
    public static String convertDateToURLFormat(final String dateToBeConvert) {
        final SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy", Locale.US);
        final SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd");
        String reformattedStr = "";
        try {
            reformattedStr = newFormat.format(oldFormat.parse(dateToBeConvert));
        } catch (final ParseException e) {
            e.printStackTrace();
        }
        return reformattedStr;
    }
}

Related

  1. convertDateToStr(Date date, String format)
  2. convertDateToString(final Date datum, final boolean withDay)
  3. convertDateToString(java.util.Date dt, String pattern)
  4. convertDateToString(String dateFormat, Date date)
  5. convertDateToString(String mask, Date date)
  6. convertStringoXSDString(Date date)
  7. convertTimeToString(Date date, String pattern)
  8. convertToString(Date date)
  9. ConvertToString(Date date, String format)