convert Date to XMLGregorianCalendar.

@param date the date
@return the xML gregorian calendar
358378
public static XMLGregorianCalendar convertDate(Date date) {
        if (date == null) {
            return null;
        }

        GregorianCalendar gc = new GregorianCalendar();
        gc.setTimeInMillis(date.getTime());

        try {
            return getDatatypeFactory().newXMLGregorianCalendar(gc);
        } catch (DatatypeConfigurationException ex) {
            return null;
        }
    }
1149188
private static Calendar dateToCalendar(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return cal;
	}
749950
public static Date beginOfWeek(@NotNull final Date date) {
		return DateUtils.truncate(DateUtil.subDays(date, DateUtil.getDayOfWeek(date) - 1), Calendar.DATE);
	}
1297225
public static String dateToString(Date date) {
        GregorianCalendar c = new GregorianCalendar(GMT);
        c.setTime(date);
        String s = calendarToString(c);
        assert s.endsWith("+00:00");
        return s.substring(0, s.length() - 6) + "-00:00";
    }
287123
private XMLGregorianCalendar createCalendar(Long timestamp) throws Exception {
        DatatypeFactory df = DatatypeFactory.newInstance();
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTimeInMillis(timestamp != null ? timestamp.longValue() : System.currentTimeMillis());
        return df.newXMLGregorianCalendar(cal);
    }
1373418
public static Integer getDayOfWeek(Date date) {

        if (date == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return calendar.get(Calendar.DAY_OF_WEEK);
    }
336065
public static PlainDate from(GregorianDate date) {

        if (date instanceof PlainDate) {
            return (PlainDate) date;
        } else {
            return PlainDate.of(date.getYear(), date.getMonth(), date.getDayOfMonth());
        }

    }
102759
public static Date dateReservedDay000(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return dateReservedDay000(calendar);
    }
935474
public static java.util.Date toJavaUtilDate(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    // Calender.MONTH starts from 0 while G C date starts from 1
    cal.set(date.year, date.month - 1, date.dayOfMonth);
    return cal.getTime();
  }
962582
protected XMLGregorianCalendar date(Long millis) {
        if (millis == null) {
            return null;
        }
        GregorianCalendar gCal = new GregorianCalendar();
        gCal.setTimeInMillis(millis);
        return dtf.newXMLGregorianCalendar(gCal);
    }
403263
protected Calendar toCalender(String date, String datePattern) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern);
        Calendar cal = Calendar.getInstance();
        try {
            cal.setTime(dateFormat.parse(date));
        } catch (ParseException e) {
            throw new CitrusRuntimeException(String.format("Error parsing date '%s' using pattern '%s'", date, datePattern), e);
        }
        return cal;
    }
536090
public static Date getCanonicalTime(Date date)
   {
      if (date != null)
      {
         Calendar cal = popCalendar(date);
         cal.set(Calendar.DAY_OF_YEAR, 1);
         cal.set(Calendar.YEAR, 1);
         cal.set(Calendar.MILLISECOND, 0);
         date = cal.getTime();
         pushCalendar(cal);
      }
      return (date);
   }
118027
private static Calendar buildCalendar(final Date date) {

    Calendar calendar = buildCalendar();
    calendar.setTime(date);
    return calendar;
  }
448903
public String dateToStringDateFormat(Date date)
   {
       if (date == null)
           return null;
       return gDateFormat.format(date);
   }
1055556
public static DateTime date(Date date) {
		if (date instanceof DateTime) {
			return (DateTime) date;
		}
		return dateNew(date);
	}
1017224
public String formatDate(Date date, int type)
    {
        String string = null;
        if (type == DBConstants.DATE_TIME_FORMAT)
            string = XmlUtilities.dateTimeFormat.format(date);
        else if (type == DBConstants.DATE_ONLY_FORMAT)
            string = XmlUtilities.dateFormat.format(date);
        else if (type == DBConstants.TIME_ONLY_FORMAT)
            string = XmlUtilities.timeFormat.format(date);
        return string;
    }
570099
public String convertDateToString(final Date date) {
        if (date == null) {
            return null;
        }
        return dateFormat.get().format(date);
    }