Here you can find the source of getDate(Calendar cal)
Parameter | Description |
---|---|
cal | Description of the Parameter |
public static java.util.Date getDate(Calendar cal)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /**/*w w w. j a va 2 s . com*/ * Returns the current time from a calendar object * * @param cal Description of the Parameter * @return The date value */ public static java.util.Date getDate(Calendar cal) { java.util.Date convertedDate = null; try { SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.SHORT); formatter.applyPattern("M/d/yyyy"); String tmpDate = (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH) + "/" + cal.get(Calendar.YEAR); convertedDate = formatter.parse(tmpDate); } catch (Exception e) { System.err.println("EXCEPTION: DateUtils -> Timestamp "); } return convertedDate; } }