aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/SynchronizedDateFormat.java
blob: 5963e2e6574cbf8dce81c379ef71e403a8d1d89c (plain)
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
package cgeo.geocaching.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class SynchronizedDateFormat {
    private final SimpleDateFormat format;

    public SynchronizedDateFormat(final String pattern, final Locale locale) {
        format = new SimpleDateFormat(pattern, locale);
    }

    public SynchronizedDateFormat(final String pattern, final TimeZone timeZone, final Locale locale) {
        format = new SimpleDateFormat(pattern, locale);
        format.setTimeZone(timeZone);
    }

    public synchronized Date parse(final String input) throws ParseException {
        return format.parse(input);
    }

    public synchronized String format(final Date date) {
        return format.format(date);
    }

}