你的位置:首页 > 操作系统

[操作系统]andriod Java中度转度分秒


public String trandu2m(double d) { //gisoracle 编号
try {
//double dd = Convert.ToDouble(str);

String str = "" + d;

int p = str.indexOf(".");
int dt = Integer.parseInt(str.substring(0, p));
d = d - dt;
double M = d * 60;
int mt = (int) M;
M = (M - mt) * 60;
if (Math.abs(M - 60) < 0.001) {
M = 0;
mt = mt + 1;

}
if (mt == 60) {
dt = dt + 1;
mt = 0;
}


return ""+dt+"°"+mt+"′"+M+"″";
} catch(Exception e) {
return e.getMessage();
}

}