yangys
2024-04-02 1a77b1a7c072b136925d6d73c4d8f017ca016e3a
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.qianwen.core.tool.time;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.function.Predicate;
import java.util.function.Supplier;
import org.joda.time.DateTime;
 
/* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/time/SampleJDKDateFormatter.class */
public class SampleJDKDateFormatter implements DateFormatter {
    Predicate<String> predicate;
    Supplier<SimpleDateFormat> formatSupplier;
 
    public SampleJDKDateFormatter(Predicate<String> predicate, Supplier<SimpleDateFormat> formatSupplier) {
        this.predicate = predicate;
        this.formatSupplier = formatSupplier;
    }
 
    @Override // org.springblade.core.tool.time.DateFormatter
    public boolean support(String str) {
        return this.predicate.test(str);
    }
 
    @Override // org.springblade.core.tool.time.DateFormatter
    public Date format(String str) {
        try {
            return this.formatSupplier.get().parse(str);
        } catch (ParseException var3) {
            var3.printStackTrace();
            return null;
        }
    }
 
    @Override // org.springblade.core.tool.time.DateFormatter
    public String getPattern() {
        return this.formatSupplier.get().toPattern();
    }
 
    @Override // org.springblade.core.tool.time.DateFormatter
    public String toString(Date date) {
        return new DateTime(date).toString(getPattern());
    }
}