Example usage for com.google.common.base Strings padEnd

List of usage examples for com.google.common.base Strings padEnd

Introduction

In this page you can find the example usage for com.google.common.base Strings padEnd.

Prototype

public static String padEnd(String string, int minLength, char padChar) 

Source Link

Document

Returns a string, of length at least minLength , consisting of string appended with as many copies of padChar as are necessary to reach that length.

Usage

From source file:eu.trentorise.opendata.jackan.CkanClient.java

/**
 * Formats a timestamp according to {@link #CKAN_TIMESTAMP_PATTERN}, with
 * precision up to microseconds.//from   w ww .j  a va 2s .  co m
 *
 * @see #parseTimestamp(java.lang.String) for the inverse process.
 * @since 0.4.1
 */
@Nullable
public static String formatTimestamp(Timestamp timestamp) {
    if (timestamp == null) {
        throw new IllegalArgumentException("Found null timestamp!");
    }
    Timestamp ret = Timestamp.valueOf(timestamp.toString());
    ret.setNanos((timestamp.getNanos() / 1000) * 1000);
    return Strings.padEnd(ret.toString().replace(" ", "T"), "1970-01-01T01:00:00.000001".length(), '0');
}