개발자/자바
JSP에서 소수점 처리
zupper
2013. 7. 24. 16:05
<%@ page contentType="text/html; charset=euc-kr"%>
<%@ page import="java.text.*"%> // 빼먹으면 안된다!
<%
DecimalFormat format = new DecimalFormat("0.00");
double a = 3.14159265358979;
double b = 1234.5678;
String c = "9876.543";
%>
a : <%= format.format(a)%><br> // a는 3.14 출력
b : <%= format.format(b)%><br> //b는 1234.57 출력
c : <%= format.format(Double.parseDouble(c))%> // c는 9876.54 출력
출처: http://blog.naver.com/PostView.nhn?blogId=roggue2&logNo=40121426677
[출처] JSP에서 소수점 반올림하기|작성자 제로