Here you can find the source of microSecondToStr(int nanos, int meta)
private static String microSecondToStr(int nanos, int meta)
//package com.java2s; /**/*from w w w . j a v a2 s . co m*/ * Project: ${puma-server.aid} * * File Created at 2012-6-11 $Id$ * * Copyright 2010 dianping.com. All rights reserved. * * This software is the confidential and proprietary information of Dianping * Company. ("Confidential Information"). You shall not disclose such * Confidential Information and shall use it only in accordance with the terms * of the license agreement you entered into with dianping.com. */ public class Main { private static String microSecondToStr(int nanos, int meta) { if (meta > 6) { throw new IllegalArgumentException("unknow useconds meta : " + meta); } String microSecond = ""; if (meta > 0) { microSecond = String.valueOf(nanos); if (microSecond.length() < meta) { int total = meta % 2 == 0 ? meta : meta + 1; int len = total - microSecond.length(); StringBuilder prefixMicroSecond = new StringBuilder(len); for (; len > 0; len--) { prefixMicroSecond.append("0"); } microSecond = prefixMicroSecond.toString() + microSecond; } microSecond = microSecond.substring(0, meta); return "." + microSecond; } return microSecond; } }