I have a string variable, in which the date can now be displayed on July 15 with that string variable? (E.g. 2012-07-15)
string string = "2012-07-15"; SimpleDateFormat formatter = New Simple Format ("yyyy-MMM-dd"); Try {d1 = formatter.parse (strdate); System.out.println (D1 + "--- previous date ---"); } Hold (ParseException e) {e.printStackTrace (); }
Your parsing template does not match your example:
SimpleDateform Format = New SimpleDateform ("YYA-MM-DD"); (with MM instead of MMM ). To output to July 15th, you can use each other Formatter:
SimpleDataformat Output = New SimpleDateform ("MMMM DD"); Println (output.format (D1)); // 15 July
Comments
Post a Comment