开发者

I need to users to enter a time in one format, convert it to another, perform a calculation, then bring it back again

I am building an app that will convert swimming times from yards to meters, and can't figure out some important stuff.

I need a user to enter a time as this: minutes:seconds.hundredths

But it has to come to me in milliseconds, so that I can perform the conversion. After that I need to put it back into that format and display it to the user.

For example, if someone swam a 200 yard Freestyle in 1:52.43, I need to figure out how to multiply it by 1.11 a开发者_如何学运维nd add 3.2 seconds, then display it to the user as their converted time for a 50 meter length pool.


If your date format is like "2011-05-31 23:59:59";

SimpleDateFormat curFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
        java.util.Date dateObj = null;
        try {
            dateObj = curFormater.parse(pDate);
            millisecond = dateObj.getTime();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 

For more info for Date formatting refer http://developer.android.com/reference/java/text/SimpleDateFormat.html


http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html

http://developer.android.com/reference/java/text/SimpleDateFormat.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜