⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parserutils.java

📁 world wind java sdk 源码
💻 JAVA
字号:
/*
Copyright (C) 2001, 2008 United States Government as represented by
the Administrator of the National Aeronautics and Space Administration.
All Rights Reserved.
*/
package gov.nasa.worldwind.applications.gio.esg;

import gov.nasa.worldwind.util.Logging;

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

/**
 * @author dcollins
 * @version $Id: ParserUtils.java 5472 2008-06-26 20:11:53Z dcollins $
 */
public class ParserUtils
{
    public ParserUtils()
    {
    }

    public static Date parseWMSDate(String s)
    {
        if (s == null)
        {
            String message = Logging.getMessage("nullValue.StringIsNull");
            Logging.logger().severe(message);
            throw new IllegalStateException(message);
        }

        // Web Map Service Implementation Specification, Annex D
        // ccyy-mm-ddThh:mm:ss.sssZ
        Date date = null;
        try
        {
            s = s.trim();
            if (s.length() > 0)
            {
                //DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSSZ");
                DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
                date = df.parse(s);
            }
        }
        catch (ParseException e)
        {
            String message = "csw.ExceptionWhileParsingCSWDate";
            Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
        }
        return date;
    }

    public static String formatAsOGCDate(Date date)
    {
        if (date == null)
        {
            String message = Logging.getMessage("nullValue.DateIsNull");
            Logging.logger().severe(message);
            throw new IllegalStateException(message);
        }

        // Web Map Service Implementation Specification, Annex D
        DateFormat df = new SimpleDateFormat("yyyy-MM");
        return df.format(date);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -