Here you can find the source of getTimeStampInMin(Date date)
public static String getTimeStampInMin(Date date)
//package com.java2s; /**//from w w w .j a v a 2 s . com * Project: zonda.logger.server * * File Created at 12-2-3 * DateUtil: DateUtil.java 12-2-3 darwin $ * * Copyright 2008 Alibaba.com Croporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Alibaba 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 Alibaba.com. */ import java.util.Calendar; import java.util.Date; public class Main { public static String getTimeStampInMin(char separator, Date date) { Calendar cal = Calendar.getInstance(); if (date != null) cal.setTime(date); StringBuilder sb = new StringBuilder(); sb.append(cal.get(Calendar.YEAR)); sb.append(separator); sb.append(padding(cal.get(Calendar.MONTH) + 1)); sb.append(separator); sb.append(padding(cal.get(Calendar.DAY_OF_MONTH))); sb.append(separator); sb.append(padding(cal.get(Calendar.HOUR_OF_DAY))); sb.append(separator); sb.append(padding(cal.get(Calendar.MINUTE))); return sb.toString(); } public static String getTimeStampInMin(Date date) { Calendar cal = Calendar.getInstance(); if (date != null) cal.setTime(date); StringBuilder sb = new StringBuilder(); sb.append(cal.get(Calendar.YEAR)); sb.append(padding(cal.get(Calendar.MONTH) + 1)); sb.append(padding(cal.get(Calendar.DAY_OF_MONTH))); sb.append("/"); sb.append(padding(cal.get(Calendar.HOUR_OF_DAY))); sb.append("/"); sb.append(padding(cal.get(Calendar.MINUTE))); return sb.toString(); } public static String padding(int i) { if (i == 0) return "00"; else if (i < 10) return "0" + i; else return "" + i; } }