blob: 5f98c167c6890897459bc6ffae5037e3c6adbbb9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package com.mitchellbosecke.pebble.extension.filters;
import com.mitchellbosecke.pebble.extension.Filter;
import com.mitchellbosecke.pebble.template.EvaluationContext;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class TimestampFilter implements Filter {
@Override
public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {
if (input instanceof Instant) {
return Date.from((Instant)input);
}
throw new IllegalArgumentException("invalid input");
}
@Override
public List<String> getArgumentNames() {
return null;
}
}
|