源代码
public String h24Toh12(String h24)
{
String dep12hStr;
int dep12h=Integer.parseInt(h24.split(":")[0]);
if(dep12h>12)
{
dep12h=dep12h-12;
dep12hStr=String.format("%02d",dep12h)+h24.substring(h24.indexOf(":"))+"P";
}
else
dep12hStr=h24+"A";
return dep12hStr;
}