[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

Very simple question somehow driving me crazy

Im brand new to JSP (having cut my teeth on PHP and ASP), Ive got the following on a webpage:

<%=obj[i].getDate()%>

It prints out "APRIL 07, 2005"

what function can I use to make it print out:

April 07, 2005

basically only the first letter of the month is capital?

lcase(obj[i].getDate()) ? Please remember Im a total novice with JSP


Also, is there a list of JSP functions somewhere (like PHP.net) ?
0
fox_statton
Asked:
fox_statton
1 Solution
 
fox_stattonAuthor Commented:
Hi,
I really want to convert the existing date, rather than generate a new one,

Thanks
0
 
GulaCommented:
You should be able to get your date's string representation into String variable:
somthing like:
String str = obj[i].getDate().toString();
You can then try to split the sring and lower-case everything after first character:
str = str.substring(0,1) + str.substring(1).toLowerCase();



What is type of obj array?
0
 
ManishLeadCommented:
In whatever format ur getting just pass that format to SimpleDateFormat and convert it into date and then
from above link u can convert it into whatever format you want...
  SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
  java.util.Date d = sdf.parse(myDate);
0
 
udilipkumarCommented:
hi,

You can you java SimpleDateFormat class to format dates in which ever form you want for display purposes. The format() method in this class takes a date object, returns a string in the format specified in the SimpleDateFormat Constructor.

To solve your problem, you need to do something of this sort....

java.util.Date toFormat = obj[i].getDate();
SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd,yyyy);
try
{
  String formattedDate = sdf.format(toFormat);
}
Catch(Exception e)
{
System.out.println("Exception in formatting date object :" + e.toString());
}

Hope this solves your problem

Cheers
Dilip Kumar
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now