当前位置: 首页>>代码示例>>Java>>正文


Java Date.parse方法代码示例

本文整理汇总了Java中java.util.Date.parse方法的典型用法代码示例。如果您正苦于以下问题:Java Date.parse方法的具体用法?Java Date.parse怎么用?Java Date.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Date的用法示例。


在下文中一共展示了Date.parse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTime

import java.util.Date; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public long getTime(Access type) {
    if (WRITE != type)
        return UNKNOWN;
    try {
        final String field = getHeaderField("last-modified");
        if (null != field)
            return Date.parse(field);
    } catch (IllegalArgumentException | IOException ex) {
    }
    return UNKNOWN;
}
 
开发者ID:christian-schlichtherle,项目名称:truevfs,代码行数:14,代码来源:HttpNode.java

示例2: checkNotModified

import java.util.Date; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public boolean checkNotModified(long lastModifiedTimestamp) {
	if (lastModifiedTimestamp >= 0 && !this.notModified &&
			(this.response == null || !this.response.containsHeader(HEADER_LAST_MODIFIED))) {
		long ifModifiedSince = -1;
		try {
			ifModifiedSince = getRequest().getDateHeader(HEADER_IF_MODIFIED_SINCE);
		}
		catch (IllegalArgumentException ex) {
			String headerValue = getRequest().getHeader(HEADER_IF_MODIFIED_SINCE);
			// Possibly an IE 10 style value: "Wed, 09 Apr 2014 09:57:42 GMT; length=13774"
			int separatorIndex = headerValue.indexOf(';');
			if (separatorIndex != -1) {
				String datePart = headerValue.substring(0, separatorIndex);
				try {
					ifModifiedSince = Date.parse(datePart);
				}
				catch (IllegalArgumentException ex2) {
					// Giving up
				}
			}
		}
		this.notModified = (ifModifiedSince >= (lastModifiedTimestamp / 1000 * 1000));
		if (this.response != null) {
			if (this.notModified && supportsNotModifiedStatus()) {
				this.response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
			}
			else {
				this.response.setDateHeader(HEADER_LAST_MODIFIED, lastModifiedTimestamp);
			}
		}
	}
	return this.notModified;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:ServletWebRequest.java

示例3: getHeaderFieldDate

import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public long getHeaderFieldDate(String name, long Default) {
    String dateString = getHeaderField(name);
    try {
        if (dateString.indexOf("GMT") == -1) {
            dateString = dateString+" GMT";
        }
        return Date.parse(dateString);
    } catch (Exception e) {
    }
    return Default;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:HttpURLConnection.java

示例4: dateTransfer

import java.util.Date; //导入方法依赖的package包/类
/**
 * 转换时间
 *
 * @param now  -1:直接格式化为yyyy-MM-dd HH:mm:ss <br />
 *             当前毫秒数:格式化为微博格式 <br />
 * @param time
 * @return
 */
public static String dateTransfer(long now, String time) {
    long createAtTime = Date.parse(time);
    Date createAt = new Date(createAtTime);
    if (now != -1) {
        long second = (now - createAtTime) / 1000L;
        if (second < 0) {
            second = 0;
        }
        if (second == 0) {
            return "刚刚";
        } else if (second < 30) {
            return second + "秒以前";
        } else if (second < 60) {
            return "半分钟前";
        } else if (second < 60 * 60) {
            return (second / 60) + "分钟前";
        } else if (second <= 60 * 60 * 3) {
            return (second / 60 / 60) + "小时前";
        } else if (getFormatTime(createAt, "d").equals(Calendar.getInstance().get(Calendar.DATE) + "")) {
            return "今天 " + getFormatTime(createAt, "HH:mm");
        } else if (getFormatTime(createAt, "d").equals((Calendar.getInstance().get(Calendar.DATE) - 1) + "")) {
            return "昨天 " + getFormatTime(createAt, "HH:mm");
        } else if (second < 60 * 60 * 24 * 7) {
            return (((second / 60) / 60) / 24) + "天前";
        } else if (getFormatTime(createAt, "yyyy").equals(Calendar.getInstance().get(Calendar.YEAR) + "")) {
            // 同一年
            return getFormatTime(createAt, "MM-dd HH:mm");
        }
        return getFormatTime(createAt, "yyyy-MM-dd HH:mm");
    } else {
        return getFormatTime(createAt, "yyyy-MM-dd HH:mm:ss");
    }
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:42,代码来源:NumberFormatter.java

示例5: parse

import java.util.Date; //导入方法依赖的package包/类
public static Date parse(String date) {
    /**The time format like "Mon Aug 01 17:04:17 +0800 2016" */
    return new Date(Date.parse(date));
}
 
开发者ID:aollio,项目名称:school-express-delivery,代码行数:5,代码来源:Test.java

示例6: getHeaderFieldDate

import java.util.Date; //导入方法依赖的package包/类
/**
 * Returns the value of the named field parsed as date.
 * The result is the number of milliseconds since January 1, 1970 GMT
 * represented by the named field.
 * <p>
 * This form of {@code getHeaderField} exists because some
 * connection types (e.g., {@code http-ng}) have pre-parsed
 * headers. Classes for that connection type can override this method
 * and short-circuit the parsing.
 *
 * @param   name     the name of the header field.
 * @param   Default   a default value.
 * @return  the value of the field, parsed as a date. The value of the
 *          {@code Default} argument is returned if the field is
 *          missing or malformed.
 */
@SuppressWarnings("deprecation")
public long getHeaderFieldDate(String name, long Default) {
    String value = getHeaderField(name);
    try {
        return Date.parse(value);
    } catch (Exception e) { }
    return Default;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:URLConnection.java


注:本文中的java.util.Date.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。