List of utility methods to do Date Convert
Date | convertDateToUTC(Date date) Returns a new Date converted to UTC Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int gmtMillisecondOffset = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)); calendar.add(Calendar.MILLISECOND, -gmtMillisecondOffset); return calendar.getTime(); |
double | convertDateToWindowsTime(Date javaDate) converts a java date to a windows time object (is this timezone safe?) if (javaDate == null) { throw new IllegalArgumentException("cannot convert null to windows time"); return convertMillisecondsToWindowsTime(javaDate.getTime()); |
long | convertDateValueToMillis(TimeZone tz, long dateValue) Convert an encoded date value to millis, using the supplied timezone. return getMillis(tz, yearFromDateValue(dateValue), monthFromDateValue(dateValue),
dayFromDateValue(dateValue), 0, 0, 0, 0);
|
Date | convertDoubleTimeToDate(Number d) convert Double Time To Date if (d == null) { return null; int m; if (d.doubleValue() < 0) { m = (int) (((long) (d.doubleValue() * DAY_MILLIS - 0.5)) % DAY_MILLIS); } else { m = (int) (((long) (d.doubleValue() * DAY_MILLIS + 0.5)) % DAY_MILLIS); ... |
Calendar | convertFromFileman(String date) convert From Fileman return date == null ? null : new GregorianCalendar(Integer.parseInt(date.substring(0, 3)) + 1700, Integer.parseInt(date.substring(3, 5)) - 1, Integer.parseInt(date.substring(5, 7))); |
String | convertInputDateToString(Date inputDate) convert input date to String String strDate = ""; Calendar c = Calendar.getInstance(); if (inputDate.equals(null)) { inputDate = new Date(); c.setTime(inputDate); strDate = c.get(Calendar.DATE) + "/" + (c.get(Calendar.MONTH) + 1) + "/" + c.get(Calendar.YEAR); return strDate; ... |
Date | convertInt2Date(int date) convert Int Date Long x = Long.valueOf(date) * 1000;
Calendar c = Calendar.getInstance();
c.setTimeInMillis(x);
return c.getTime();
|
Date | convertIntToDate(final int iDate) Converts an integer time in the form of YYYYMMDD to the proper Date if (iDate == 0) { return null; calendar.clear(); int year = iDate / 10000; if (year > 1700) { int tmp = (iDate - (year * 10000)); int month = tmp / 100; ... |
Date | convertIntToDate(final int iDate, final StringBuilder verbatimDate) Converts an integer time in the form of YYYYMMDD to the proper Date calendar.clear(); int year = iDate / 20000; if (year > 1600) { int tmp = (iDate - (year * 20000)); int month = tmp / 100; int day = (tmp - (month * 100)); if (month == 0 || day == 0) { verbatimDate.setLength(0); ... |
Date | convertLocalDateToUTCDate(Date localDate) convert Local Date To UTC Date Calendar cal = Calendar.getInstance(); int tzOffset = cal.get(Calendar.ZONE_OFFSET); TimeZone tz = cal.getTimeZone(); if (tz.inDaylightTime(localDate)) { tzOffset += cal.get(Calendar.DST_OFFSET); Date UTCDate = new Date(); UTCDate.setTime(localDate.getTime() - tzOffset); ... |