Blackberry hh:mm aa(12小时格式)转换为hh:mm(24小时格式)
我有Blackberry hh:mm aa(12小时格式)转换为hh:mm(24小时格式),blackberry,java-me,time,Blackberry,Java Me,Time,我有String time=“02:30 PM”表示12小时格式,我想将此时间转换为24小时格式 我要这个o/p:14:30。那么我如何转换它呢?试试这段代码 这将提供24小时格式的当前时间 SimpleDateFormat formate = new SimpleDateFormat("HH:mm"); String newTime = formate.formatLocal(System.currentTimeMillis()); 试试这个代码 这将提供24小时格式的当前时
String time=“02:30 PM”
表示12小时格式,我想将此时间转换为24小时格式
我要这个o/p:14:30
。那么我如何转换它呢?试试这段代码
这将提供24小时格式的当前时间
SimpleDateFormat formate = new SimpleDateFormat("HH:mm");
String newTime = formate.formatLocal(System.currentTimeMillis());
试试这个代码
这将提供24小时格式的当前时间
SimpleDateFormat formate = new SimpleDateFormat("HH:mm");
String newTime = formate.formatLocal(System.currentTimeMillis());
我对berries一无所知,但如果API缺少正确的格式化函数,您总是可以用字符串本身弄脏您的手:
static String convert(String time){
boolean pm = "PM".equals(time.substring(6).toUpperCase());
int h = Integer.valueOf(time.substring(0,2));
if (h!=12)
h+=pm?12:0;
else
h=pm?h:0;
return ((h<10)?"0":"")+h + ":" + time.substring(3,5);
}
静态字符串转换(字符串时间){
布尔pm=“pm.”等于(time.substring(6.toUpperCase());
int h=整数.valueOf(time.substring(0,2));
如果(h!=12)
h+=pm?12:0;
其他的
h=pm?h:0;
return((h我对berries一无所知,但如果API缺少正确的格式化函数,您总是可以用字符串本身弄脏您的手:
static String convert(String time){
boolean pm = "PM".equals(time.substring(6).toUpperCase());
int h = Integer.valueOf(time.substring(0,2));
if (h!=12)
h+=pm?12:0;
else
h=pm?h:0;
return ((h<10)?"0":"")+h + ":" + time.substring(3,5);
}
静态字符串转换(字符串时间){
布尔pm=“pm.”等于(time.substring(6.toUpperCase());
int h=整数.valueOf(time.substring(0,2));
如果(h!=12)
h+=pm?12:0;
其他的
h=pm?h:0;
返回((hTag only blackberry,所以人们只输入blackberry的代码。在第一个发送的问题中,有时删除Java标记后也有Java标记参见重复:删除了我的答案-没有意识到blackberry的限制。只输入blackberry的标记,所以人们只输入blackberry的代码。在第一个发送的问题中,有时删除Java标记后也有Java标记dSee复制:删除了我的答案-没有意识到黑莓的限制。