Dear all,
I have textbox (txtTransDate)
that I set text to '2008-04-17' because mySQL accepts that format date.
I want to change the format to "MM/dd/yyyy" 04-17-2008 to retrieve month and year.
But the error is like this :java.text.ParseException: Unparseable date: "2008-04-17"
int tahun =0, bln=0 ;
String sBln="";
SimpleDateFormat dtChange = new SimpleDateFormat("MM/dd/yyyy");
try
{
Date date = dtChange.parse(txtTransDate.getText().trim());
tahun = date.getYear() + 1900;
bln = date.getMonth() + 1;
sBln = Integer.toString(bln);
if(sBln.length()==1)
{
sBln = "0" + sBln;
}
}
catch(Exception e)
{
System.out.println(e.toString());
}