Android Open Source - ProjectTimer Time Util






From Project

Back to project page ProjectTimer.

License

The source code is released under:

Copyright (c) 2012 Alex Wu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software w...

If you think the Android project ProjectTimer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cooltofu;
/*from   w  ww  .  j a va 2s  . com*/
public class TimeUtil {
  private static final String TIME_FORMAT = "%02d:%02d:%02d";
  
  public static String formatTimeTextDisplay(int seconds) {
    int hour = seconds / 3600;
    int rem = seconds % 3600;
    int min = rem / 60;
    int sec = rem % 60;

    return String.format(TIME_FORMAT, hour, min, sec);
  }
  
  public static int convertToSeconds(String t) {
    // t variable is in the format of: 00:00:00
    // hh:mm:ss
    int sec = 0;

    String[] timeStr = t.split(":");
    if (timeStr[0] != "00") {
      // convert hours into seconds
      int h = Integer.parseInt(timeStr[0]) * 60 * 60;
      sec += h;
    }

    if (timeStr[1] != "00") {
      // convert minutes into seconds
      int m = Integer.parseInt(timeStr[1]) * 60;
      sec += m;
    }

    if (timeStr[2] != "00") {
      // convert minutes into seconds
      int s = Integer.parseInt(timeStr[2]);
      sec += s;
    }

    return sec;
  }
}




Java Source Code List

com.cooltofu.Eula.java
com.cooltofu.MoreScreen.java
com.cooltofu.MyTimer.java
com.cooltofu.ProjectTimerActivity.java
com.cooltofu.TimeUtil.java
com.cooltofu.db.TimerDbAdapter.java
com.cooltofu.db.TimerDbHelper.java
com.cooltofu.db.TimerTable.java
com.cooltofu.util.Base64DecoderException.java
com.cooltofu.util.Base64.java
com.cooltofu.util.IabException.java
com.cooltofu.util.IabHelper.java
com.cooltofu.util.IabResult.java
com.cooltofu.util.Inventory.java
com.cooltofu.util.Purchase.java
com.cooltofu.util.Security.java
com.cooltofu.util.SkuDetails.java