Here you can find the source of getTimeStr3(Calendar timeInstance)
Parameter | Description |
---|---|
timeInstance | calendar instance |
public static String getTimeStr3(Calendar timeInstance)
//package com.java2s; import java.util.*; public class Main { /**/*from w w w.java 2 s . c o m*/ * Returns a string of the time instance in string format for internal use. <br><br> * Complete date plus hours, minutes and seconds:<br> * YYYYMMDDhhmmss (eg 19970716192030) * @param timeInstance calendar instance * @return time in string */ public static String getTimeStr3(Calendar timeInstance) { Calendar time = timeInstance; int field; String year = "", month = "", day = "", hour = "", minute = "", second = ""; String timeStr = ""; field = time.get(Calendar.YEAR); if (field < 10) { year = "000"; } year = year + Integer.toString(field); field = time.get(Calendar.MONTH) + 1; if (field < 10) { month = "0"; } month = month + Integer.toString(field); field = time.get(Calendar.DAY_OF_MONTH); if (field < 10) { day = "0"; } day = day + Integer.toString(field); field = time.get(Calendar.HOUR_OF_DAY); if (field < 10) { hour = "0"; } hour = hour + Integer.toString(field); field = time.get(Calendar.MINUTE); if (field < 10) { minute = "0"; } minute = minute + Integer.toString(field); field = time.get(Calendar.SECOND); if (field < 10) { second = "0"; } second = second + Integer.toString(field); timeStr = year + month + day + hour + minute + second; return timeStr; } }