Java String Trim Right rightTrimString(String originalString)

Here you can find the source of rightTrimString(String originalString)

Description

Returns a new string with all space characters removed from the right

License

Open Source License

Parameter

Parameter Description
originalString - timestamp representation of date

Return

- String

Declaration

public static String rightTrimString(String originalString) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 1998, 2015 Oracle and/or its affiliates. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
 * which accompanies this distribution./*w w  w.  j  ava 2 s  .  c  om*/
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 *     dminsky - added countOccurrencesOf(Object, List) API
 *     08/23/2010-2.2 Michael O'Brien
 *        - 323043: application.xml module ordering may cause weaving not to occur causing an NPE.
 *                       warn if expected "_persistence_*_vh" method not found
 *                       instead of throwing NPE during deploy validation.
 ******************************************************************************/

public class Main {
    /**
     * Returns a new string with all space characters removed from the right
     *
     * @param originalString - timestamp representation of date
     * @return  - String
     */
    public static String rightTrimString(String originalString) {
        int len = originalString.length();
        while ((len > 0) && (originalString.charAt(len - 1) <= ' ')) {
            len--;
        }
        return originalString.substring(0, len);
    }
}

Related

  1. rightTrim(String[] values)
  2. rightTrim(StringBuilder pStringBuilder)
  3. rightTrimNewLineChars(String input)
  4. rightTrimSize(String s)
  5. rightTrimSlashes(String s)
  6. rtrim(final String input)
  7. rtrim(final String str)
  8. rtrim(final String str, final char filler)
  9. rtrim(final String text)