-2

I can convert the string to date, but when I want to convert the string in other type of data it is wrong.

String string = "1995 11 07";
SimpleDateFormat fmt = new SimpleDateFormat("cccc F MMMM yyyy", Locale.getDefault());
date = fmt.parse(string);
Toast.makeText(getContext(), date.toString(), Toast.LENGTH_LONG).show();

What is the correct practice?

рüффп
  • 5,172
  • 34
  • 67
  • 113
Eric Retamero
  • 29
  • 1
  • 7
  • 2
    You're specifying your desired *output* format as your *parsing* format. You need two `SimpleDateFormat` objects - one with your input format, to parse, and then one with your output format, to format... – Jon Skeet May 27 '16 at 10:39
  • http://stackoverflow.com/questions/4216745/java-string-to-date-conversion/ – Tom May 27 '16 at 10:40
  • Please search and study Stack Overflow before posting. – Basil Bourque May 27 '16 at 17:49

1 Answers1

0
String input_date="01/08/2012";
SimpleDateFormat format1=new SimpleDateFormat("dd/MM/yyyy");
Date dt1=format1.parse(input_date);
DateFormat format2=new SimpleDateFormat("EEEE"); 
String finalDay=format2.format(dt1)