on 09-23-2008 10:50 AM
I have a date in yyyy-mm-dd format stored in a string.
I want to display the date in dd-mmm-yyyy format in jsp.
please provide me the code for the same.
Get 10 pts for right answer.
Hi anzar naik,
Try this,
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-YYYY");
Date beforeDate=null;
beforeDate=sdf.parse(Your_Date);
Hope it will help you. Thanks.
Regards,
Kathiresan R
Note:
Points are welcome
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can try this way...
SimpleDateFormat dateFormat;
dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); //format can be dd-MM-yy or dd-MM-yyyy also
String strformatteddate=dateFormat.format(Your Date to be formatted);
but it returns date in string format...
Regards,
Srinivas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you could try something like this
public class ChangeData
{
public static void main(String args[])
{
String initDate = "yyyy-mm-dd";
String newDate = "";
String a,b,c;
a = initDate.substring(initDate.lastIndexOf("-")+1);
b = initDate.substring(0,initDate.indexOf("-"));
c = initDate.substring(initDate.indexOf("-")+1,initDate.lastIndexOf("-"));
newDate = a"-"c"-"b;
System.out.println(newDate);
}
}//dd-mmm-yyyy
now do note that this code will only work if the input is always in the form of "yyyy-mm-dd"
Thanks,
GLM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.