Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cant get this to work

Status
Not open for further replies.

chaddu1256

IS-IT--Management
Jan 13, 2003
28
US
java.text.DecimalFormat decimalFormat = new java.text.DecimalFormat("0.0000");

this is at the top of the page and the code which im trying to use this is as follows

<%
//to test for null values
String va1 = &quot;&quot;;
if (utilWrap1.getExtension8().toString().equals(&quot;0.000000&quot;)){
va1 = &quot; &quot;;
}
else{
va1 = decimalFormat.format(Double.parseDouble(utilWrap1.getExtension8()
}
%>
<td> <div align=&quot;center&quot;><font size=&quot;2&quot;><%=va1%></font></div></td>

Basically whats going on is Extension8 is pulling in a water meter reading from our oracle database. The default format for this meter reading is 0.000000 what we are trying to do is format this from 6 decimal places to 4 decimal places, but also to say that if the reading is 0 then dont show anything. Im having trouble applying formatting and the null statement to the same thing. Any help would be great. Thanx
 
I can't see any problems with your method there really (apart from a missing ')' on this line &quot;va1 = decimalFormat.format(Double.parseDouble(utilWrap1.getExtension8()&quot;.

You may be able to do it with a tertiary statement, but your way is fine (unless I'm missing something ?!) ...
 
i figured it out

va1 = decimalFormat.format(Double.parseDouble(utilWrap1.getExtension8()));

it works now so im gtg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top