Hello Java Gurus,
I'm attaching some sample code from my server. I'm basically getting some weird error from second block of my code below.
The second block contains if/else; and having hard time to fix variable issue. I'm newbie, learning java.
The first block and second block contains similar code except that second block contains if/else.
I've to use if/else in second block to filter data with null value.
How do I fix the if/else block? If I remove if/else block, the code works just fine.
Your help is greatly appreciated.
-----------------------first block works without issue----------------------------------------
java.util.Date creationTime=userProperties.getDate("CREATE_TIME") ;
String DATE_FORMAT="MM/dd/yyyy";
SimpleDateFormat sdf=new SimpleDateFormat(DATE_FORMAT);
out.println ("Creation Time : "+sdf.format(creationTime)+"<br>");
--------------------second block if/else this one does not work-------------------------------
if(userProperties.getProperty("LAST_LOGTIME") != null) /* This field contains date and null value*/
{
java.util.Date lastLoginTime=userProperties.getDate("LAST_LOGTIME ");
String LAST_DATE="MM/dd/yyyy";
SimpleDateFormat lastdatesdf=new SimpleDateFormat(LAST_DATE);
out.println ("Creation Time : "+lastdatesdf.format(lastLoginTime)+"<br>");
}
else
{
lastLoginTime=" ";
}
---------------------if/else creates this error block-----------------------
lastLoginTime cannot be resolved to a variable
73: }
74: else
75: {
76: lastLoginTime=" ";
77: }
----------------------------------------------------------------------------
Thanks,
Zulu