change Date Format - Android java.util

Android examples for java.util:Date Format

Description

change Date Format

Demo Code


//package com.java2s;

import java.text.DateFormat;

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

public class Main {
    public static String changeDateFormat(String mdate)
            throws ParseException {
        DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
        Date d = df.parse(mdate);
        df = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(df.format(d));

        return df.format(d);
    }/*from   w  w  w . ja  v  a 2  s. c  o  m*/
}

Related Tutorials