I'm having trouble changing the date format to dd/MMM/yyyy
.
Here is my current implementation:
final String OLD_FORMAT = "yyyy-MM-dd";
final String NEW_FORMAT = "yyyy-MMM-dd";
//Start Date
String str4=label.getText();
java.util.Date toDate = null;
//System.out.println(str4);
//End Date
String str5=lblNewLabel_3.getText();
java.util.Date newDateString = null;
SimpleDateFormat format = new SimpleDateFormat(OLD_FORMAT);
try {
toDate=format.parse(str4);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
newDateString=format.parse(str5);
format.applyLocalizedPattern(NEW_FORMAT);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
output: [Tue May 28 00:00:00 WST 2013]
can someone help me with this, thanks! :D
I add this while statement then the date format sets to default again..
System.out.println("From " + toDate);
System.out.println("To " + newDateString );
Calendar cal2 = Calendar.getInstance();
cal2.setTime(toDate);
System.out.println(toDate);
while (cal2.getTime().before(newDateString)) {
cal2.add(Calendar.DATE, 1);
Object datelist=(cal2.getTime());
List<Object> wordList = Arrays.asList(datelist);
System.out.println(wordList);
}