Blackberry: how to convert time from String in “hhhh:mm:ss.ss” to “mm:ss” formate

元气小坏坏 提交于 2019-12-25 08:05:57

问题


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.


回答1:


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('.'));


来源:https://stackoverflow.com/questions/9892156/blackberry-how-to-convert-time-from-string-in-hhhhmmss-ss-to-mmss-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!