Java Second trimMiliSeconds(String time)

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

Description

trim Mili Seconds

License

Open Source License

Declaration

public static String trimMiliSeconds(String time) 

Method Source Code

//package com.java2s;
/**/*from   w  ww .ja va  2 s  . c  o  m*/
 * Copyright (c) 2015 SK holdings Co., Ltd. All rights reserved.
 * This software is the confidential and proprietary information of SK holdings.
 * You shall not disclose such confidential information and shall use it only in
 * accordance with the terms of the license agreement you entered into with SK holdings.
 * (http://www.eclipse.org/legal/epl-v10.html)
 */

public class Main {
    public static String trimMiliSeconds(String time) {
        if (time.matches("[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.[0-9]")
                || time.matches(
                        "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.[0-9][0-9]")
                || time.matches(
                        "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\\.[0-9][0-9][0-9]")) {
            int index = time.indexOf('.');
            return time.substring(0, index);
        }

        return time;
    }
}

Related

  1. timeStringToSeconds(String input)
  2. timeStringToSeconds(String time)
  3. timeToSeconds(String in)
  4. timeToSeconds(String textTime)
  5. timeToSeconds(String time)
  6. validateSecond(int second)
  7. valueOfSecond(long time)