将日期转换成自定义格式的字符串

@param datetime 日期
@param sdf 自定义格式

@return 自定义格式的字符串
187780
public static String datetimeToCustomString(SimpleDateFormat sdf, Date datetime) {
        return Checker.isNull(datetime) ? "" : sdf.format(datetime);
    }
1244085
String getElapsedFormatted(DateFormat _dateFormat, long _elapsedTime) {
        Date elapsedTime = new Date(_elapsedTime);

        DateFormat sdf = _dateFormat;
        if (_dateFormat == null) {
            sdf = new SimpleDateFormat("HH:mm:ss.SSS");
        }
        sdf.setTimeZone(TimeZone.getTimeZone("UTC")); // always use UTC so we get the correct time without timezone offset on it

        return sdf.format(elapsedTime);
    }
1131214
@Deprecated
	public static String getDateStringSecond(long time) {
		Date date=new Date(time);
		Calendar C=Calendar.getInstance();
		C.setTime(date);
		int day=C.get(Calendar.DATE);
		int hour=C.get(Calendar.HOUR_OF_DAY);
		int minute=C.get(Calendar.MINUTE);
		int second=C.get(Calendar.SECOND);
		return
			(day>=0 && day<=9 ? "0":"")
			+day
			+MONTHS[C.get(Calendar.MONTH)]
			+C.get(Calendar.YEAR)
			+' '
			+(hour>=0 && hour<=9 ? "0":"")
			+hour
			+':'
			+(minute>=0 && minute<=9 ? "0":"")
			+minute
			+':'		
			+(second>=0 && second<=9 ? "0":"")
			+second
		;
	}
798926
public static DateTime toDateTime(org.joda.time.DateTime dateTime) {
    return dateTimesHelper.toDateTime(dateTime);
  }
1028844
private List<Skeleton> parseDateTimeSkeletons(JsonObject calendar) {
    JsonObject node = resolve(calendar, "dateTimeFormats", "availableFormats");
    List<Skeleton> value = new ArrayList<>();
    for (String key : objectKeys(node)) {
      value.add(new Skeleton(key, string(node, key)));
    }
    return value;
  }
284686
public static String getDateString(String format, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
1327968
public DateTime toDateTime(T dateTime) {
    try {
      @SuppressWarnings("unchecked") // Expected class.
      D dateObj = (D) PropertyUtils.getProperty(dateTime, "date");
      String timeZoneId =
          PropertyUtils.isReadable(dateTime, "timeZoneId")
              ? (String) PropertyUtils.getProperty(dateTime, "timeZoneId")
              : (String) PropertyUtils.getProperty(dateTime, "timeZoneID");
      return new DateTime(
          (Integer) PropertyUtils.getProperty(dateObj, "year"),
          (Integer) PropertyUtils.getProperty(dateObj, "month"),
          (Integer) PropertyUtils.getProperty(dateObj, "day"),
          (Integer) PropertyUtils.getProperty(dateTime, "hour"),
          (Integer) PropertyUtils.getProperty(dateTime, "minute"),
          (Integer) PropertyUtils.getProperty(dateTime, "second"),
          0,
          DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId)));
    } catch (IllegalAccessException e) {
      throw new IllegalStateException("Could not access class.", e);
    } catch (InvocationTargetException e) {
      throw new IllegalStateException("Could not get field.", e);
    } catch (NoSuchMethodException e) {
      throw new IllegalStateException("Could not get field.", e);
    }
  }
761192
public static String getDateStr(Date date) {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }
322212
public static Date parseDate(TimeType timeType, String date) {
        SimpleDateFormat sdf = getDateFormat(timeType);
        try {
            return sdf.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
37454
private DateTime[] asDateTime( List<Object> values ) {
        ValueFactory<DateTime> factory = valueFactories.getDateFactory();
        DateTime[] res = new DateTime[values.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = factory.create(((GregorianCalendar)values.get(i)).getTime());
        }
        return res;
    }
834151
public static int getDaysOfMonth(Date date) {
		DateTime dt = new DateTime(date.getTime());
		return getDaysOfMonth(dt.getYear(), dt.getMonthOfYear());
	}
309294
public static String toStringWithMinutes( DateTime dateTime ) {
        String dtStr = dateTime.toString(withMinutesformatter);
        return dtStr;
    }
625368
public static final String formatTime(long timestamp) {
        DateFormat sdf = dateformats.get();
        if (sdf == null) {
            sdf = getDateFormat();
            dateformats.set(sdf);
        }
        return sdf.format(timestamp);
    }
564370
public static  String formatTime(String dateValue, FastDateFormat sdf) {
        try {
            return FDF_OUT_TIME.format(sdf.parse(dateValue));
        } catch (ParseException ex) {
            LOG.debug(String.format("Fehler beim Parsen des Datums %s: %s", dateValue, ex.getMessage()));
        }
        
        return "";
    }
1360803
public static Calendar toCalendar(String dateTimeString) throws ParseException {

        Date date = toDate(dateTimeString);
        if (date == null) {
            return (null);
        }

        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return (cal);
    }
142414
private void _serializeDateTime(DateTime dateTime, StringBuilder sb) {

	Calendar c = JREDateTimeUtil.getThreadCalendar(ThreadLocalPageContext.getTimeZone());
	c.setTime(dateTime);
	sb.append(goIn());
	sb.append("new Date(");
	sb.append(c.get(Calendar.YEAR));
	sb.append(",");
	sb.append(c.get(Calendar.MONTH));
	sb.append(",");
	sb.append(c.get(Calendar.DAY_OF_MONTH));
	sb.append(",");
	sb.append(c.get(Calendar.HOUR_OF_DAY));
	sb.append(",");
	sb.append(c.get(Calendar.MINUTE));
	sb.append(",");
	sb.append(c.get(Calendar.SECOND));
	sb.append(");");
    }
952725
public static String getDateTimeStrConcise(Date d) {
        if (d == null)
            return "";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
        return sdf.format(d);
    }