Java Time Format formatTime(String time)

Here you can find the source of formatTime(String time)

Description

format Time

License

Open Source License

Declaration

final static String formatTime(String time) 

Method Source Code

//package com.java2s;
/**/*from w w  w  .ja v a2 s .  co  m*/
 * @copyright Copyright (C) 2014-2016 City of Bloomington, Indiana. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
 * @author W. Sibo <sibow@bloomington.in.gov>
 *
 */

public class Main {
    final static String formatTime(String time) {
        String ret = time;
        if (time.length() > 0 && time.indexOf(":") == -1) {
            if (time.length() == 4) {
                ret = time.substring(0, 2) + ":" + time.substring(2);
            } else if (time.length() == 3) {
                ret = "0" + time.substring(0, 1) + ":" + time.substring(1);
            }
        }
        return ret;

    }
}

Related

  1. formatTime(long value)
  2. FormatTime(String strTime, char TimeSepartor)
  3. formatTime(String time)
  4. formatTime(String time)
  5. formatTime(String time)
  6. formatTime(String timeStr)
  7. formatTime14To12String(String time)
  8. formatTime2(long secs)
  9. formatTime2(long timeInSeconds)