I thinking what is the best way in Java to parse the String with this format dd/MM/yyyy [to dd/MM/yyyy]. The string with the [] are optional and dd stand for the 2 digit pre
you can do something like this -
String input = "02/08/2010 [to 31/12/2010]";
java.text.DateFormat format = new java.text.SimpleDateFormat("dd/MM/yyyy");
java.util.Date d = null;
try {
d = format.parse(input.split(" ")[0]);
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(d) ;
if string with the [] is not present still input.split(" ")[0]
will return the first string only.