All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.efaps.ui.wicket.util.DateUtil Maven / Gradle / Ivy

Go to download

eFaps WebApp provides a web interface as the User Interface for eFaps which can be easily expanded and altered.

There is a newer version: 3.2.0
Show newest version
/*
 * Copyright 2003 - 2012 The eFaps Team
 *
 * 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.
 *
 * Revision:        $Rev: 7532 $
 * Last Changed:    $Date: 2012-05-19 01:31:05 -0500 (Sat, 19 May 2012) $
 * Last Changed By: $Author: [email protected] $
 */

package org.efaps.ui.wicket.util;

import org.apache.wicket.datetime.StyleDateConverter;
import org.efaps.db.Context;
import org.efaps.util.EFapsException;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

/**
 * Singelton class for date functions.
 *
 * @author The eFaps Team
 * @version $Id: DateUtil.java 7532 2012-05-19 06:31:05Z [email protected] $
 */
public final class DateUtil
{
    /**
     * Singelton.
     */
    private DateUtil()
    {
    }

    /**
     * Convert a date from a parameter into a DateTime.
     *
     * @param _value value to be converted
     * @return DateTime
     * @throws EFapsException on error
     */
    public static DateTime getDateFromParameter(final String _value)
        throws EFapsException
    {
        final StyleDateConverter styledate = new StyleDateConverter(false);
        final DateTimeFormatter fmt = DateTimeFormat.forPattern(styledate.getDatePattern(Context.getThreadContext()
                        .getLocale()));
        fmt.withLocale(Context.getThreadContext().getLocale());
        final DateTime dt = fmt.parseDateTime(_value);
        return dt;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy