Here you can find the source of normalizeVersion(String version, int length)
public static String normalizeVersion(String version, int length)
//package com.java2s; /*/*from w ww . ja va 2 s . c om*/ * Copyright (c) Mirth Corporation. All rights reserved. * * http://www.mirthcorp.com * * The software in this package is published under the terms of the MPL license a copy of which has * been included with this distribution in the LICENSE.txt file. */ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.ListIterator; public class Main { /** * Normalizes a version string so that it has 'length' number of version numbers separated by '.' */ public static String normalizeVersion(String version, int length) { if (version == null) { return null; } List<String> numbers = new ArrayList<String>(Arrays.asList(version .split("\\."))); while (numbers.size() < length) { numbers.add("0"); } StringBuilder builder = new StringBuilder(); for (ListIterator<String> iterator = numbers.listIterator(); iterator .hasNext() && iterator.nextIndex() < length;) { String number = iterator.next(); if (iterator.hasNext() && iterator.nextIndex() < length) { builder.append(number + "."); } else { builder.append(number); } } return builder.toString(); } }