Android examples for java.util:Date Convert
Convert date value from one format to another format
import android.annotation.SuppressLint; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main{ public static String string2String(String str, String format, String secondFormat) { try {// w w w.j a va 2 s . c o m return date2String(new SimpleDateFormat(format).parse(str) .getTime(), secondFormat); } catch (ParseException e) { e.printStackTrace(); } return new Date().toString(); } }