• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A challenge while formatting date value from the database

 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I'm fetching a set of data from the database which includes some date values.
This is my code:

When we run:

Now I want to format the date in dd/MM/yyyy format for which I use SimpleDateFormat class

My code now:

But now the output is:


It's not displaying other datas, once it encounters the first null value in date.
But when we don't use formatting, these null values are also getting displayed.
Now, my requirement is
1) I want to display the date value in a formatted manner
2) If atall some null date values are there it should be presented as null.
I want the output to be in this format.

sai : 11850 : 26/09/2006
azees : 11851 : null
jothish : 11856 : null
pradap : 11859 : 12/12/2006


How can i achieve this?
Regards.
 
ramya narayanan
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The challenge is won now , by including a simple if statement after fetching the date value & checking for null value.
Note the whole output is formatted using String.format method which is highlighted.
Code:


Output:


Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic