Retrieve a finish date time in the form required by Phoenix.

@param value Date instance
@return formatted date time
421375
public static final String printFinishDateTime(Date value)
   {
      if (value != null)
      {
         value = DateHelper.addDays(value, 1);
      }
      return (value == null ? null : DATE_FORMAT.get().format(value));
   }
857945
public static DateTime toDateTime(Timestamp value) {
        if (value == null) {
            return null;
        } else {
            return new DateTime(value.getTime(), DateTimeZone.UTC);
        }
    }
1177719
public static String getAsString(Object value) {
		String result = null;
		if (value == null) {
			result = "";
		} else if (value instanceof Double) {
			double n = (Double) value;
			result = n == (long) n ? String.format("%d",(long) n) : String.format("%s", n);
		} else if (value instanceof Date) {
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
			String date = df.format((Date) value);

			result = date.substring(0, date.length() - 2) + ":" + date.substring(date.length() - 2, date.length());
		} else {
			result = value.toString();
		}

		return result;
	}
309515
public function fromDateTime($value)
    {
        return empty($value) ? $value : $this->asDateTime($value)
            ->timezone($this->getTimezone())
            ->format($this->getFormat());
    }
305895
public static final Duration parseDuration(String value)
   {
      return value == null ? null : Duration.getInstance(Double.parseDouble(value), TimeUnit.DAYS);
   }
316232
public static String formatIsoDate(ZonedDateTime value) {
        if (value == null) {
            return null;
        }

        // to match the format we get from Python's .isoformat(), we don't include second fraction if it's zero
        if (value.getNano() == 0) {
            return ISO_DATETIME_FORMAT_NO_SECOND_FRACTION.format(value);
        }

        return ISO_DATETIME_FORMAT.format(value);
    }
812684
private String getFormattedDate(Date date) {
		String formattedDate = "";
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		try {
			formattedDate = ValueFactoryImpl.getInstance().createValue(cal).getString();
		} catch (Exception e) {
			// should never happen
			e.printStackTrace();
		}
		return formattedDate;
	}
931941
public static String toNullableString(Object value) {
		// Shortcuts
		if (value == null)
			return null;
		if (value instanceof String)
			return (String) value;

		// Legacy and new dates
		if (value instanceof Date)
			value = ZonedDateTime.ofInstant(((Date) value).toInstant(), ZoneId.systemDefault());
		if (value instanceof Calendar) {
			value = ZonedDateTime.ofInstant(((Calendar) value).toInstant(),
					((Calendar) value).getTimeZone().toZoneId());
		}
		if (value instanceof Duration)
			value = ((Duration) value).toMillis();
		if (value instanceof Instant)
			value = ZonedDateTime.ofInstant((Instant) value, ZoneId.systemDefault());
		if (value instanceof LocalDateTime)
			value = ZonedDateTime.of((LocalDateTime) value, ZoneId.systemDefault());
		if (value instanceof LocalDate)
			value = ZonedDateTime.of((LocalDate) value, LocalTime.of(0, 0), ZoneId.systemDefault());
		if (value instanceof ZonedDateTime)
			return ((ZonedDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);

		// Convert list
		if (value instanceof List<?>) {
			StringBuilder builder = new StringBuilder();
			for (Object element : (List<?>)value) {
				if (builder.length() > 0)
					builder.append(",");
				builder.append(element);
			}
			return builder.toString();
		}

		// Convert array
		if (value.getClass().isArray()) {
			StringBuilder builder = new StringBuilder();
			int length = Array.getLength(value);
			for (int index = 0; index < length; index++) {
				if (builder.length() > 0)
					builder.append(",");
				builder.append(Array.get(value, index));
			}
			return builder.toString();
		}
		
		
		// Everything else
		return value.toString();
	}
583003
public static final String printDate(Date value)
   {
      return (value == null ? null : DATE_FORMAT.get().format(value));
   }
1007524
public static String formatTimeISO8601(TimeValue value) {
		StringBuilder builder = new StringBuilder();
		DecimalFormat yearForm = new DecimalFormat(FORMAT_YEAR);
		DecimalFormat timeForm = new DecimalFormat(FORMAT_OTHER);
		if (value.getYear() > 0) {
			builder.append("+");
		}
		builder.append(yearForm.format(value.getYear()));
		builder.append("-");
		builder.append(timeForm.format(value.getMonth()));
		builder.append("-");
		builder.append(timeForm.format(value.getDay()));
		builder.append("T");
		builder.append(timeForm.format(value.getHour()));
		builder.append(":");
		builder.append(timeForm.format(value.getMinute()));
		builder.append(":");
		builder.append(timeForm.format(value.getSecond()));
		builder.append("Z");
		return builder.toString();
	}
427141
private String formatDateTime(Object value)
   {
      String result = null;
      if (value instanceof Date)
      {
         result = m_formats.getDateTimeFormat().format(value);
      }
      return result;
   }
1139800
public String correctDurationValue(String value) {
		if (value.matches("PT[0-9]+H")){
			for (MatchResult mr : Toolbox.findMatches(Pattern.compile("PT([0-9]+)H"), value)){
				try {
					int hours = Integer.parseInt(mr.group(1));
					if ((hours % 24) == 0){
						int days = hours / 24;
						value = "P"+days+"D";
					}
				} catch(NumberFormatException e) {
					Logger.printDetail(component, "Couldn't do granularity conversion for " + value);
				}
			}
		} else if (value.matches("PT[0-9]+M")){
			for (MatchResult mr : Toolbox.findMatches(Pattern.compile("PT([0-9]+)M"), value)){
				try {
					int minutes = Integer.parseInt(mr.group(1));
					if ((minutes % 60) == 0){
						int hours = minutes / 60;
						value = "PT"+hours+"H";
					}
				} catch(NumberFormatException e) {
					Logger.printDetail(component, "Couldn't do granularity conversion for " + value);
				}
			}
		} else if (value.matches("P[0-9]+M")){
			for (MatchResult mr : Toolbox.findMatches(Pattern.compile("P([0-9]+)M"), value)){
				try {
					int months = Integer.parseInt(mr.group(1));
					if ((months % 12) == 0){
						int years = months / 12;
						value = "P"+years+"Y";
					}
				} catch(NumberFormatException e) {
					Logger.printDetail(component, "Couldn't do granularity conversion for " + value);
				}
			}
		}
		return value;
	}
431204
public static final Date parseExtendedAttributeDate(String value)
   {
      Date result = null;

      if (value != null)
      {
         try
         {
            result = DATE_FORMAT.get().parse(value);
         }

         catch (ParseException ex)
         {
            // ignore exceptions
         }
      }

      return (result);
   }
17380
public static Calendar read(String value) {
		Date date=DateUtils.read(value);
		
		Calendar calendar=Calendar.getInstance();
		calendar.setTime(date);
		
		return calendar;
	}
191353
private String formatDuration(Object value)
   {
      String result = null;
      if (value instanceof Duration)
      {
         Duration duration = (Duration) value;
         result = m_formats.getDurationDecimalFormat().format(duration.getDuration()) + formatTimeUnit(duration.getUnits());
      }
      return result;
   }
494805
public static java.util.Date getDateTime(Object value) {
        try {
            return toDateTime(value);
        } catch (ParseException pe) {
            pe.printStackTrace();
            return null;
        }
    }
804057
public static long getLongWithCurrentDate(String value, String timezone) {
    if (Strings.isNullOrEmpty(value)) {
      return 0;
    }

    DateTime time = getCurrentTime(timezone);
    DateTimeFormatter dtFormatter = DateTimeFormat.forPattern(CURRENT_DATE_FORMAT).withZone(time.getZone());
    if (value.toUpperCase().startsWith(CURRENT_DAY)) {
      return Long
          .parseLong(dtFormatter.print(time.minusDays(Integer.parseInt(value.substring(CURRENT_DAY.length() + 1)))));
    }
    if (value.toUpperCase().startsWith(CURRENT_HOUR)) {
      return Long
          .parseLong(dtFormatter.print(time.minusHours(Integer.parseInt(value.substring(CURRENT_HOUR.length() + 1)))));
    }
    return Long.parseLong(value);
  }