Android Date String Parse convertDateStringToDash(String MonthDayYear)

Here you can find the source of convertDateStringToDash(String MonthDayYear)

Description

convert Date String To Dash

Declaration

@SuppressLint("SimpleDateFormat")
    public static String convertDateStringToDash(String MonthDayYear) 

Method Source Code

//package com.java2s;
import java.text.DateFormat;

import java.text.SimpleDateFormat;

import java.util.Date;
import android.annotation.SuppressLint;

public class Main {
    @SuppressLint("SimpleDateFormat")
    public static String convertDateStringToDash(String MonthDayYear) {
        String convertedDate = "";
        SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
        Date date;//w w  w . ja v a 2 s .  co m
        try {
            date = formatter.parse(MonthDayYear);
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            convertedDate = df.format(date);

        } catch (Exception e) {

        }

        return convertedDate;
    }
}

Related

  1. toDateFormat(String d, String delim)
  2. parseDate(CharSequence input)
  3. parseDate(CharSequence input, Date defaultDate)
  4. parseDate(CharSequence input, String pattern, Date defaultDate)
  5. convertDate(String YearMonthDay)
  6. convertDateStringToLong(String date, String format)
  7. convertDateTime( String YearMonthDayHourMinuteSeconds)
  8. convertToDate(String dateString)
  9. getDateFromString(String format, String dateString)