当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.leftPad方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.leftPad方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.leftPad方法的具体用法?Java StringUtils.leftPad怎么用?Java StringUtils.leftPad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.leftPad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RequestIdManager

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public RequestIdManager(String serviceId) {
  if (serviceId == null) {
    serviceIdTag = "9999";
  }
  if (serviceId.length() > SERVICE_ID_TAG_LENGTH) {
    serviceIdTag = StringUtils
        .substring(serviceId, serviceId.length() - SERVICE_ID_TAG_LENGTH, serviceId.length() - 1);
  } else {
    serviceIdTag = StringUtils.leftPad(serviceId, SERVICE_ID_TAG_LENGTH, '0');
  }
}
 
开发者ID:eXcellme,项目名称:eds,代码行数:12,代码来源:RequestIdManager.java

示例2: AbstractCodeWriter

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public AbstractCodeWriter(Appendable appendable, int spaces){
    if (appendable == null){
        throw new IllegalArgumentException("appendable is null");
    }
    this.appendable = appendable;
    this.spaces = spaces;
    this.spacesString = StringUtils.leftPad("", spaces);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:AbstractCodeWriter.java

示例3: describe

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public String describe()
{
	if (this.days.size() == 0 || this.times.length == 0)
	{
		return "NEVER";
	}
	String description = "";
	String s = "";
	if (this.days.size() == 7)
	{
		s = "DAILY";
	}
	else
	{
		for (Weekday weekday : this.days)
		{
			s += (s.isEmpty() ? "" : ", ") + weekday.name();
		}
	}
	description = s;
	s = "";
	for (int time : this.times)
	{
		int hour = time / 60;
		int minute = time % 60;
		s += (s.isEmpty() ? "" : ", ") + StringUtils.leftPad("" + hour, 2, "0") + ":" + StringUtils.leftPad("" + minute, 2, "0");
	}
	description += " at " + s;
	return description;
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:31,代码来源:CustomEvent.java

示例4: formatTime

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * @param hoursExpression
 * @param minutesExpression
 * @param secondsExpression
 * @return
 */
public static String formatTime(String hoursExpression, String minutesExpression, String secondsExpression) {
    int hour = Integer.parseInt(hoursExpression);
    String amPM = hour >= 12 ? I18nMessages.get("time_pm") : I18nMessages.get("time_am");
    if (hour > 12) {
        hour -= 12;
    }
    String minute = String.valueOf(Integer.parseInt(minutesExpression));
    String second = "";
    if (!StringUtils.isEmpty(secondsExpression)) {
        second = ":" + StringUtils.leftPad(String.valueOf(Integer.parseInt(secondsExpression)), 2, '0');
    }
    return MessageFormat.format("{0}:{1}{2} {3}", String.valueOf(hour), StringUtils.leftPad(minute, 2, '0'), second, amPM);
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:20,代码来源:DateAndTimeUtils.java

示例5: visit

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void visit(Table table) {
    String tableWholeName = table.getName();
    
    String tableOrginName = table.getName();
    String index = String.valueOf(MVEL.eval(this.expression, this.param));
    String suffix = StringUtils.leftPad(index, 4, "0");
    table.setName(tableOrginName + AbstractTableRouter.TABLE_NAME_SLIPTOR + suffix);
    
    tables.add(tableWholeName);
}
 
开发者ID:devpage,项目名称:sharding-quickstart,代码行数:12,代码来源:TablesNamesFinder.java

示例6: toBinaryString

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 将ip地址转换为二进制字符串
 * @param ip 255.255.255.255
 * @return
 */
public static final String toBinaryString(String ip) {
	if (ip == null || "".equals(ip)) {
		return null;
	}
	String[] ipAddress = StringUtils.split(ip, ".");
	StringBuilder builder = new StringBuilder();
	for (String ipAdd : ipAddress) {
		String binaryString = Integer.toBinaryString(Integer.parseInt(ipAdd));
		binaryString = StringUtils.leftPad(binaryString, 8, "0");
		builder.append(binaryString);
	}
	return builder.toString();
}
 
开发者ID:babymm,项目名称:mumu,代码行数:19,代码来源:IPAddressUtil.java

示例7: transformLongToIpAddress

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * int数字转换为ip地址
 * @param ip ip地址
 * @return
 */
public static final String transformLongToIpAddress(int intIpAddress){
	String binaryString = Integer.toBinaryString(intIpAddress);
	binaryString = StringUtils.leftPad(binaryString, 32, "0");
	StringBuilder ipAddress=new StringBuilder();
	for (int i = 0; i < 4; i++) {
		String substring = binaryString.substring(i*8, (i+1)*8);
		ipAddress.append(toLong(substring));
		if(i<3){
			ipAddress.append(".");
		}
	}
	return ipAddress.toString();
}
 
开发者ID:babymm,项目名称:mumu,代码行数:19,代码来源:IPAddressUtil.java

示例8: digitalClockQuantity

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Format a duration in milliseconds to a digital clock string
 *
 * @param millis The amount of millis
 * @return A string: [hours:]minutes:seconds
 */
public String digitalClockQuantity(long millis) {
  Duration duration = new Duration(millis);
  Function<Long, String> pad = l -> StringUtils.leftPad(String.valueOf(l), 2, "0");

  long hours = duration.getStandardHours();
  long minutes = duration.getStandardMinutes() - (hours * 60);
  long seconds = duration.getStandardSeconds() - (minutes * 60 + hours * 3600);

  if (hours > 0) {
    return pad.apply(hours) + ':' + pad.apply(minutes) + ':' + pad.apply(seconds);
  }
  return pad.apply(minutes) + ':' + pad.apply(seconds);
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:20,代码来源:TimeFormatter.java

示例9: generateId

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String generateId() {
    return "T"
            + StringUtils.leftPad(
            Long.toString(new DateTime().minus(Period.years(45)).getMillis(), 36).toUpperCase(),
            9,
            '0');
}
 
开发者ID:SAP,项目名称:cloud-s4-sdk-examples,代码行数:8,代码来源:CostCenterServiceIntegrationTest.java

示例10: getDuration

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getDuration(int durationInSec) {
    int minutes = durationInSec / 60;
    int seconds = durationInSec % 60;

    String minutesStr = String.valueOf(minutes);
    String secondsStr = String.valueOf(seconds);
    return StringUtils.leftPad(minutesStr, 2, '0') + ":" + StringUtils.leftPad(secondsStr, 2, '0');
}
 
开发者ID:ruslanys,项目名称:vkmusic,代码行数:9,代码来源:AudioTableModel.java

示例11: saveSeats

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private Seat saveSeats(int i) {

		String credentials = StringUtils.leftPad(String.valueOf(i), 3, "0");
		Seat seat = new Seat(credentials, credentials);

		// if (i % 2 == 0) {
		// s.setFanName("Fan n" + credentials);
		// }

		// generate random points ranging from 1 to max
		// s.setPoints(n.nextInt(max - 1 + 1) + 1);

		seat = seatRepository.save(seat);
		return seat;
	}
 
开发者ID:edylle,项目名称:hockey-game,代码行数:16,代码来源:ApplicationStartup.java

示例12: deelsOnbekendeDatumAlsGetalNaarString

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Zet een getals representatie van een deels onbekende datum (formaat = yyyy-MM-dd) om naar een tekstuele representatie die dezelfde datum representeert.
 * @param datum getalsrepresentatie van een deels onbekende datum
 * @return tekstuele representatie van een deels onbekende datum, null indien tekstuele representatie (1) null is, (2) leeg is of (3) een invalide
 * formaat heeft
 */
public static String deelsOnbekendeDatumAlsGetalNaarString(final Integer datum) {
    final String datumAlsString = String.valueOf(datum);
    if (datum != null) {
        final boolean lengteValide = datum == 0 || datumAlsString.length() >= LENGTE_JAAR+1 && datumAlsString.length() <= LENGTE_DATUM;
        if (lengteValide) {
            final StringBuilder deelsOnbekendeDatum = new StringBuilder(StringUtils.leftPad(datumAlsString, LENGTE_DATUM, NUL_ALS_STRING));
            deelsOnbekendeDatum.insert(LENGTE_JAAR + LENGTE_MAAND, "-").insert(LENGTE_JAAR, "-");
            if (new DeelsOnbekendeDatum(deelsOnbekendeDatum.toString()).isGeldig()) {
                return deelsOnbekendeDatum.toString();
            }
        }
    }
    return null;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:21,代码来源:DatumFormatterUtil.java

示例13: generateMask

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String generateMask(int length) {
	return StringUtils.leftPad("", length, "*");
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:4,代码来源:CommonUtils.java

示例14: describeTime

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public String describeTime()
{
	return StringUtils.leftPad("" + (this.start / 60), 2, "0") + ":" + StringUtils.leftPad("" + (this.start % 60), 2, "0") + " - " + StringUtils.leftPad("" + (this.end / 60), 2, "0") + ":" + StringUtils.leftPad("" + (this.end % 60), 2, "0");
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:5,代码来源:SleepEntry.java

示例15: padZeroesLeft

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String padZeroesLeft(String s, int n) {
    return StringUtils.leftPad(s, n, '0');
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:4,代码来源:TestUtils.java


注:本文中的org.apache.commons.lang3.StringUtils.leftPad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。