java 时间毫秒转换成hhmmss

 

java 时间毫秒转换成hhmmss

 

 

package com.iteye.injavawetrust.ad;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.TimeZone;
import java.util.UUID;

/**
 * 毫秒转换成秒hhmmss
 * @author InJavaWeTrust
 *
 */
public class TestDate {
	
	/**
	 * 毫秒转换成hhmmss
	 * @param ms 毫秒
	 * @return hh:mm:ss
	 */
	public static String msToss(long ms) {
		SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
		formatter.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
		String ss = formatter.format(ms);
		return ss;
	}
	
	public static void main(String[] args) {
		long startTime = System.currentTimeMillis();
		int max = 1000000;  
		List values = new ArrayList<>(max);  
		for (int i = 0; i < max; i++) {  
		    UUID uuid = UUID.randomUUID();  
		    values.add(uuid.toString());  
		} 
		long endTime = System.currentTimeMillis();
		System.out.println("用时[" + TestDate.msToss(endTime - startTime) + "]");
		
	}

}

 

你可能感兴趣的:(java 时间毫秒转换成hhmmss)