Here you can find the source of formatSerialNumber(final BigInteger serial)
Parameter | Description |
---|---|
serial | The certificate's serial number. |
public static String formatSerialNumber(final BigInteger serial)
//package com.java2s; /***************************************************************************** * Copyright (c) 2008 g-Eclipse Consortium * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Initial development of the original code was made for the * g-Eclipse project founded by European Union * project number: FP6-IST-034327 http://www.geclipse.eu/ * * Contributors:/* w w w . j av a2s .c o m*/ * Mathias Stuempert - initial API and implementation *****************************************************************************/ import java.math.BigInteger; public class Main { /** * Get a proper string representation of a certificate's serial number. * * @param serial The certificate's serial number. * @return A string representation of the serial number. */ public static String formatSerialNumber(final BigInteger serial) { StringBuffer b = new StringBuffer(serial.toString(16).toUpperCase()); if ((b.length() % 2) != 0) { b.insert(0, "0"); //$NON-NLS-1$ } int index = 2; for (index = 2; index < b.length(); index += 3) { b.insert(index, ":"); //$NON-NLS-1$ } return b.toString(); } }