Blackberry:如何从"hhhh:mm:ss.ss"中的String转换时间到"mm:ss"甲酸盐 [英] Blackberry: how to convert time from String in "hhhh:mm:ss.ss" to "mm:ss" formate

查看:79
本文介绍了Blackberry:如何从"hhhh:mm:ss.ss"中的String转换时间到"mm:ss"甲酸盐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带时间的字符串,我想将其转换为其他格式.我尝试了几种方法,其中一些是荒谬的,因为将字符串转换为char数组,并将数字转换为冒号等.但是我失败了,而且我没有足够的时间自己找到方法.

I have a String with time and I want to convert it to other format. I try several soulutions and some of them was a ridiculous as convert string to char array and find numbers to colons etc. But I fail in that and I haven't enough time to found way by themselves.

能给我个解决办法吗?这种转换并不常见,但可能您已经找到了解决方案. 谢谢.

Can you give me a solution? This convertaion not usual but probably you have got a solution. Thanks.

推荐答案

格式"hhhh:mm:ss.ss"似乎不常见.但是,如果您使用任何标准日期格式,则可以使用以下代码段:

The format "hhhh:mm:ss.ss" seems unusual. But if you use any standard date format then you can use following code segments:

SimpleDateFormat sd = new SimpleDateFormat("hh:mm");
String time = sd.formatLocal(HttpDateParser.parse("2010-03-27 09:45:10"));

但是,如果您更喜欢原始字符串处理,则可以使用如下代码:

But if you prefer raw string processing then you can use some like this:

String input = "hhhh:mm:ss.ss";     
String output = input.substring(input.indexOf(':') + 1, input.indexOf('.'));

这篇关于Blackberry:如何从"hhhh:mm:ss.ss"中的String转换时间到"mm:ss"甲酸盐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆