格式化日期格式

@param argDate
@param argFormat
@return 格式化后的日期字符串
170021
public static String formatDate(Date argDate, String argFormat) throws Exception {
        if (argDate == null) {
            throw new Exception("参数[日期]不能为空!");
        }
        if (argFormat == null || argFormat.length() == 0) {
            argFormat = Y_M_D;
        }
        SimpleDateFormat sdfFrom = new SimpleDateFormat(argFormat);
        return sdfFrom.format(argDate).toString();
    }
483755
def serialize_args(args)
      return {} if args.nil?

      args.each do |key, value|
        case value
        when DateTime, Time
          args[key] = value.strftime('%m/%d/%Y %H:%M:%S')
        when Date
          args[key] = value.strftime('%m/%d/%Y')
        else
          # Especially for range operator (...), we want to output as String
          args[key] = value.to_s
        end
      end

      args
    end
809003
def _datetime_to_date(arg):
    
    _arg = parse(arg)
    if isinstance(_arg, datetime.datetime):
        _arg = _arg.date()
    return _arg
1329315
def in_date(objet, pattern):
        
        if objet:
            pattern = re.sub(" ", '', pattern)
            objet_str = abstractRender.date(objet)
            return bool(re.search(pattern, objet_str))
        return False
735359
public synchronized static Date convertFromAgmipDateString(String agmipDate) {
        try {
            return dateFormatter.parse(agmipDate);
        } catch (Exception ex) {
            return null;
        }
    }
219135
def format_date_argument(date_element):
    
    if not isinstance(date_element, (datetime.datetime, datetime.date)):
        # TODO:
        if "T" in date_element:
            _date = datetime.datetime.strptime(date_element, "%Y-%m-%dT%H:%M:%S")
        else:
            _date = datetime.datetime.strptime(date_element, "%Y-%m-%d").date()
    else:
        _date = date_element
    return _date.isoformat()
458396
private void evalDateTime(MessageArg arg) {
    if (!arg.resolve()) {
      return;
    }
    
    initCalendarArgsParser();
    parseArgs(calendarArgsParser);
    
    ZonedDateTime datetime = parseDateTime(arg);
    CalendarFormatter formatter = CLDR_INSTANCE.getCalendarFormatter(locale);
    formatter.format(datetime, calendarArgsParser.options(), buf);
  }
621007
public HandyDate date(Object expression, Object arg2) {
        if (arg2 instanceof TimeZone) {
            if (expression instanceof LocalDate) {
                return create((LocalDate) expression, (TimeZone) arg2);
            }
            if (expression instanceof LocalDateTime) {
                return create((LocalDateTime) expression, (TimeZone) arg2);
            }
            if (expression instanceof String) {
                return create((String) expression, (TimeZone) arg2);
            }
            String msg =
                    "First argument as two arguments should be LocalDate or LocalDateTime or String(expression) when second argument is TimeZone: "
                            + expression;
            throw new TemplateProcessingException(msg);
        }
        if (arg2 instanceof String) {
            if (expression instanceof String) {
                return create((String) expression, (String) arg2);
            }
            String msg = "First argument as two arguments should be String when second argument is String(pattern): " + expression;
            throw new TemplateProcessingException(msg);
        }
        String msg = "Second argument as two arguments should be TimeZone or String(pattern): " + arg2;
        throw new TemplateProcessingException(msg);
    }
352385
public static String getPreOrNextDay(Date date,int num) {
        Calendar   ca   =   Calendar.getInstance();
        ca.setTime(date);
        ca.add(Calendar.DAY_OF_MONTH,  num);//此处要用add方法
        Date   firstDate   =   ca.getTime();
        return dateToString(firstDate);
    }
1324545
public static String formatDate(@NotNull String pattern, @NotNull Date date) {
		return FastDateFormat.getInstance(pattern).format(date);
	}
411186
function toUTCDateString(arg) {
    var d = dateify(arg);
    var date = new Date(d.getTime() + d.getTimezoneOffset() * 60 * 1000);

    var _destructure3 = destructure(date);

    var _destructure4 = _slicedToArray(_destructure3, 6);

    var yr = _destructure4[0];
    var mn = _destructure4[1];
    var dy = _destructure4[2];
    var hr = _destructure4[3];
    var min = _destructure4[4];
    var sec = _destructure4[5];

    return yr + '-' + _padInt(mn + 1) + '-' + _padInt(dy) + ('T' + _padInt(hr) + ':' + _padInt(min) + ':' + _padInt(sec) + 'Z');
  }
887318
public static Integer getRemainingDayOfMonth(Date date) {

        if (date == null)
            return null;

        // 月天数
        int days = getDayNumOfMonth(date);
        // 第几天
        int dayOfMonth = getDayOfMonth(date);

        return days - dayOfMonth;
    }
1308606
public static String[] toWhereArgs(Object... args) {
		String[] arr = new String[args.length];
		for (int i = 0; i < args.length; i++) {
			Object arg = args[i];
			String argStr;
			if (arg == null) {
				argStr = "NULL";
			} else if (arg instanceof Boolean) {
				argStr = ((Boolean) arg) ? "1" : "0";
			} else if (arg instanceof Date) {
				argStr = String.valueOf(((Date) arg).getTime());
			} else if (arg instanceof Entity) {
				argStr = String.valueOf(((Entity) arg)._id);
			} else {
				argStr = arg.toString();
			}
			arr[i] = argStr;
		}
		return arr;
	}
476731
public static Date parseDate(final String date, final List<String> patterns)
	{
		for (final String pattern : patterns)
		{
			final SimpleDateFormat formatter = new SimpleDateFormat(pattern);
			try
			{
				return formatter.parse(date);
			}
			catch (final ParseException e)
			{
				// Do nothing...
			}
		}
		return null;
	}
633673
function(arg) {
  var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
  last = new Date();
  fs.write(tmpfile, JSON.stringify(args) + '\n', 'a');
}
457616
public boolean inThisDay(Date theTargetDate) {
		Date[] thisDay = asDayRange();
		return theTargetDate.compareTo(thisDay[0]) >= 0 && theTargetDate.compareTo(thisDay[1]) <= 0;
	}
300162
public static String formatDate(Date date) {
        SimpleDateFormat formatter = new SimpleDateFormat(TIMESTAMP_FORMAT);
        return formatter.format(date);
    }