Here you can find the source of currentXdsDate(int format)
public static String currentXdsDate(int format)
//package com.java2s; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { public static final int CCR_FORMAT = 1; public static final int HL7_FORMAT = 2; public static final int XDS_FORMAT = 3; public static String currentXdsDate(int format) { TimeZone tz = TimeZone.getTimeZone("GMT"); Calendar cal = new GregorianCalendar(tz); return getXdsDate(cal, format); }/* w w w.j a va 2 s . co m*/ private static String getXdsDate(Calendar cal, int format) { int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; int dom = cal.get(Calendar.DAY_OF_MONTH); int hour = cal.get(Calendar.HOUR_OF_DAY); int min = cal.get(Calendar.MINUTE); int sec = cal.get(Calendar.SECOND); String monthStr, domStr, hourStr, minStr, secStr; if (month < 10) { monthStr = "0" + month; } else { monthStr = String.valueOf(month); } if (dom < 10) { domStr = "0" + dom; } else { domStr = String.valueOf(dom); } if (hour < 10) { hourStr = "0" + hour; } else { hourStr = String.valueOf(hour); } if (min < 10) { minStr = "0" + min; } else { minStr = String.valueOf(min); } if (sec < 10) { secStr = "0" + sec; } else { secStr = String.valueOf(sec); } String xdsDateString = null; switch (format) { case CCR_FORMAT: xdsDateString = year + "-" + monthStr + "-" + domStr + "T" + hourStr + ":" + minStr + ":" + secStr + "Z"; break; case HL7_FORMAT: xdsDateString = year + monthStr + domStr + "T" + hourStr + ":" + minStr + ":" + secStr + "Z"; break; case XDS_FORMAT: xdsDateString = year + monthStr + domStr + hourStr + minStr + secStr; break; default: break; } return xdsDateString; } }