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

com.iobeam.api.resource.util.Util Maven / Gradle / Ivy

There is a newer version: 0.6.1
Show newest version
package com.iobeam.api.resource.util;

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

/**
 * Resource utilities.
 */
public class Util {

    public static final SimpleDateFormat DATE_FORMAT =
        new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");

    public static Date parseToDate(String dateStr) throws ParseException {
        Date created;
        try {
            created = Util.DATE_FORMAT.parse(dateStr);
        } catch (ParseException e) {
            try {
                final Calendar c = javax.xml.bind.DatatypeConverter.parseDateTime(dateStr);
                created = c.getTime();
            } catch (IllegalArgumentException e2) {
                throw e;
            }
        }
        return created;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy