Here you can find the source of toStringDateTimeMillisecond(Calendar calendar)
Parameter | Description |
---|---|
calendar | a parameter |
public static String toStringDateTimeMillisecond(Calendar calendar)
//package com.java2s; /*/*from ww w.ja va 2 s .c o m*/ * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.util.Calendar; public class Main { private static final int BUDDHIST_YEAR = 543; /** * @param calendar * @return String ("20130101010101001") * @example String dateUI = * DateUtils.convertCalendarToStringDateTimeMillisecond( * DateUtils.getCurrentDateCalendarEng() ); */ public static String toStringDateTimeMillisecond(Calendar calendar) { String yyyy = String.valueOf(calendar.get(Calendar.YEAR) + BUDDHIST_YEAR); String mm = String.valueOf(calendar.get(Calendar.MONTH) + 1); String dd = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); String hh = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)); String nn = String.valueOf(calendar.get(Calendar.MINUTE)); String ss = String.valueOf(calendar.get(Calendar.SECOND)); String ms = String.valueOf(calendar.get(Calendar.MILLISECOND)); if (mm.length() < 2) { mm = "0" + mm; } if (dd.length() < 2) { dd = "0" + dd; } if (hh.length() < 2) { hh = "0" + hh; } if (nn.length() < 2) { nn = "0" + nn; } if (ss.length() < 2) { ss = "0" + ss; } if (ms.length() == 1) { ms = "00" + ms; } else if (ms.length() == 2) { ms = "0" + ms; } return yyyy + mm + dd + hh + nn + ss + ms; } }