Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * getNotiPercent * * @param progress * @param max * @return */ public static Integer getNotiPercent(long progress, long max) { int rate = 0; if (progress <= 0 || max <= 0) { rate = 0; } else if (progress > max) { rate = 100; } else { rate = (int) ((double) progress / max * 100); } return Integer.valueOf(new StringBuilder(16).append(rate).toString()); } }