Converts a {@link java.util.Date} to a timestamp. Date is accurate to
milliseconds, so the last 6 digits are always going to be zeros.

@param date the date to convert
@return a new timestamp
345188
public static Timestamp of(Date date) {
        if (date == null)
            return null;
        long time = date.getTime();
        int nanoSec = (int) (time % 1000) * 1000000;
        long epochSec = (time / 1000);
        return createWithCarry(epochSec, nanoSec);
    }
655779
function formatDate(date) {
  let timestamp;
  if (date instanceof Date) {
    // Datadog expects seconds.
    timestamp = Math.round(date.getTime() / 1000);
  } else if (date instanceof Number) {
    // Make sure it is an integer, not a float.
    timestamp = Math.round(date);
  }
  return timestamp;
}
1045689
public Date dateValue(String date) {
		Date value = null;
		if (date != null) {

			// Try each simple date formatter in order
			ParseException exception = null;
			for (SimpleDateFormat sdf : formatters) {
				try {
					synchronized (sdf) {
						value = sdf.parse(date);
					}
					break;
				} catch (ParseException e) {
					if (exception == null) {
						exception = e;
					}
				}
			}

			// If no value could be parsed throw the first expected parse
			// format exception
			if (value == null) {
				throw new GeoPackageException("Failed to parse date string: "
						+ date, exception);
			}

		}
		return value;
	}
853488
public static DateTime offsetMillisecond(Date date, int offset) {
		return offset(date, DateField.MILLISECOND, offset);
	}
256656
public static int getMinutes(final Date date)
	{
		final Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		return calendar.get(Calendar.MINUTE);
	}
623293
public TimestampInterval on(PlainDate date) {

        return TimestampInterval.between(
            date.at(this.getStartAsClockTime()),
            date.at(this.getEndAsClockTime()));

    }
981948
private Date timestampToDate(Timestamp ts) {
    long millis = ts.getTime();
    int nanos = ts.getNanos();
    return new Date(millis / 1000 * 1000 + nanos / 1000000);
  }
638206
public String format(Date date) {
		Calendar cal = new GregorianCalendar();
		cal.setTime(date);
		return DatatypeConverter.printDateTime(cal);
	}
822624
public static Date dateReservedMonth000(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);

        return dateReservedMonth000(calendar);
    }
1134744
public static java.sql.Date getSqlDate(java.util.Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return new java.sql.Date(cal.getTimeInMillis());
    }
345343
@Override
    public Calendar convertDateToCalendar(java.util.Date date) {
        Calendar calendar = null;
        if (date != null) {
            calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.clear(Calendar.ZONE_OFFSET);
            calendar.clear(Calendar.DST_OFFSET);
        }
        return calendar;
    }
310444
public void setDate(String date) {
        if (date == null || date.trim().isEmpty()) {
            throw new IllegalArgumentException("Date cannot be null or empty.");
        }
        try {
            Date dateToSet = new SimpleDateFormat("MM/dd/yyyy").parse(date);
            Calendar to = Calendar.getInstance();
            to.setTime(dateToSet);
            setDate(to);
        } catch (ParseException e) {
            throw new IllegalArgumentException(e);
        }
    }
264730
public String dateToMWTimeStamp(Date date) {
    SimpleDateFormat mwTimeStampFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    String result = mwTimeStampFormat.format(date);
    return result;
  }
995956
public static String dateToString(Date date) {
        final TimeZone utc = TimeZone.getTimeZone("UTC");

        SimpleDateFormat tformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
        tformat.setTimeZone(utc);
        return tformat.format(date);
    }
1176675
public static Date beginOfMinute(@NotNull final Date date) {
		return DateUtils.truncate(date, Calendar.MINUTE);
	}
1345894
public static String unixDateToString(int date) {
		final StringBuilder buf = new StringBuilder(10);
		unixDateToString(buf, date);
		return buf.toString();
	}
1179344
public static final Long date2utc(Date date) {

        // use null for a null date
        if (date == null) return null;
        
        long time = date.getTime();
        
        // remove the timezone offset        
        time -= timezoneOffsetMillis(date);
        
        return time;
    }