/*
 * Copyright 2012 s_wolff.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.aegee.runanddine.util;

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

/**
 * Converts generic Date objects into the german date format
 * @author s_wolff
 */
public class DateFormat {

    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy");

    /**
     * Format date in german date format
     * @param date Date to to formatted
     * @return Formatted german date
     */
    public static String format(Date date) {
        return DATE_FORMAT.format(date);
    }

    /**
     * Parse date in german format to Date object
     * @param string Date in german format
     * @return Parsed date object
     * @throws ParseException 
     */
    public static Date parse(String string) throws ParseException {
        return DATE_FORMAT.parse(string);
    }
}
