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


Java DateUtils类代码示例

本文整理汇总了Java中org.archive.util.DateUtils的典型用法代码示例。如果您正苦于以下问题:Java DateUtils类的具体用法?Java DateUtils怎么用?Java DateUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: writeWARCInfoRecord

import org.archive.util.DateUtils; //导入依赖的package包/类
public void writeWARCInfoRecord(OutputStream out, 
                                String filename, 
                                byte[] contents ) throws IOException
{
  // WARC/1.0
  // WARC-Type: warcinfo
  // WARC-Date: 2010-10-08T07:00:26Z
  // WARC-Filename: LOC-MONTHLY-014-20101008070022-00127-crawling111.us.archive.org.warc.gz
  // WARC-Record-ID: <urn:uuid:05de9500-7047-4206-aa7f-346a0dc91b1f>
  // Content-Type: application/warc-fields
  // Content-Length: 600

  HttpHeaders headers = new HttpHeaders();
  headers.add(HEADER_KEY_TYPE, WARCRecordType.warcinfo.name());
  headers.add(HEADER_KEY_DATE, DateUtils.getLog14Date());
  headers.add(HEADER_KEY_FILENAME, filename);
  headers.add(HEADER_KEY_ID, makeRecordId());
  headers.add(CONTENT_TYPE,WARC_FIELDS_TYPE);
  writeRecord(out,headers,contents);
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:21,代码来源:WARCRecordWriter.java

示例2: writeJSONMetadataRecord

import org.archive.util.DateUtils; //导入依赖的package包/类
public void writeJSONMetadataRecord( OutputStream out,
                                     byte[] contents,
                                     String targetURI,
                                     Date originalDate,
                                     String origRecordId ) throws IOException
{
  HttpHeaders headers = new HttpHeaders();
  headers.add(HEADER_KEY_TYPE, WARCRecordType.metadata.name());
  headers.add(HEADER_KEY_URI, targetURI);
  headers.add(HEADER_KEY_DATE, DateUtils.getLog14Date(originalDate));
  headers.add(HEADER_KEY_ID, makeRecordId());
  headers.add(HEADER_KEY_REFERS_TO, origRecordId);
  
  headers.add(CONTENT_TYPE,"application/json");
  writeRecord(out, headers, contents);
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:17,代码来源:WARCRecordWriter.java

示例3: writeRequest

import org.archive.util.DateUtils; //导入依赖的package包/类
protected URI writeRequest(URI id) throws IOException, ParseException {
  WARCRecordInfo record = new WARCRecordInfo();

  record.setType(WARCConstants.WARCRecordType.request);
  record.setUrl(getUrl());
  record.setCreate14DigitDate(DateUtils
      .getLog14Date(Long.parseLong(metadata.get("nutch.fetch.time"))));
  record.setMimetype(WARCConstants.HTTP_REQUEST_MIMETYPE);
  record.setRecordId(GENERATOR.getRecordID());

  if (id != null) {
    ANVLRecord headers = new ANVLRecord();
    headers.addLabelValue(WARCConstants.HEADER_KEY_CONCURRENT_TO,
        '<' + id.toString() + '>');
    record.setExtraHeaders(headers);
  }

  ByteArrayOutputStream output = new ByteArrayOutputStream();

  output.write(metadata.get("_request_").getBytes());
  record.setContentLength(output.size());
  record.setContentStream(new ByteArrayInputStream(output.toByteArray()));

  writer.writeRecord(record);

  return record.getRecordId();
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:28,代码来源:CommonCrawlFormatWARC.java

示例4: Instance

import org.archive.util.DateUtils; //导入依赖的package包/类
public Instance( String waybackTimestamp, String url ) {
this.waybackTimestamp = waybackTimestamp;
try {
    this.timestamp = DateUtils.getDate(waybackTimestamp);
} catch (ParseException e) {
    Logger.error("Could not parse capturedate "+this.waybackTimestamp);
    this.timestamp = null;
}
this.url = url;
   }
 
开发者ID:ukwa,项目名称:ukwa,代码行数:11,代码来源:Instance.java

示例5: writeWARCMDRecord

import org.archive.util.DateUtils; //导入依赖的package包/类
private void writeWARCMDRecord(OutputStream recOut, MetaData md, 
			String targetURI, String capDateString, String recId)
	throws IOException {

                ByteArrayOutputStream bos = new ByteArrayOutputStream();

		OutputStreamWriter osw = new OutputStreamWriter(bos, UTF8);
		try {
			md.write(osw);
		} catch (JSONException e1) {
			e1.printStackTrace();
			throw new IOException(e1);
		}
		osw.flush();
//		ByteArrayInputStream bais = new ByteArrayInputStream(md.toString().getBytes("UTF-8"));
		Date capDate;
		try {
			capDate = DateUtils.getSecondsSinceEpoch(capDateString);

		} catch (ParseException e) {
			e.printStackTrace();
			// TODO... not the write thing...
			capDate = new Date();
		}
		
		recW.writeJSONMetadataRecord(recOut, bos.toByteArray(),
				targetURI, capDate, recId);
	}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:29,代码来源:WATExtractorOutput.java

示例6: parseDate

import org.archive.util.DateUtils; //导入依赖的package包/类
private void parseDate(ARCMetaData data, final String ds, boolean strict)
throws ARCFormatException {
	try {
		Date d = DateUtils.getDate(ds);
		data.setDateBoth(d,ds);
	} catch (ParseException e) {
		throw new ARCFormatException("Bad date(" + ds + ")");
	}
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:10,代码来源:ARCMetaDataParser.java

示例7: writeResponse

import org.archive.util.DateUtils; //导入依赖的package包/类
protected URI writeResponse() throws IOException, ParseException {
  WARCRecordInfo record = new WARCRecordInfo();

  record.setType(WARCConstants.WARCRecordType.response);
  record.setUrl(getUrl());

  String fetchTime;

  record.setCreate14DigitDate(DateUtils
      .getLog14Date(Long.parseLong(metadata.get("nutch.fetch.time"))));
  record.setMimetype(WARCConstants.HTTP_RESPONSE_MIMETYPE);
  record.setRecordId(GENERATOR.getRecordID());

  String IP = getResponseAddress();

  if (StringUtils.isNotBlank(IP))
    record.addExtraHeader(WARCConstants.HEADER_KEY_IP, IP);

  if (ParseSegment.isTruncated(content))
    record.addExtraHeader(WARCConstants.HEADER_KEY_TRUNCATED, "unspecified");

  ByteArrayOutputStream output = new ByteArrayOutputStream();

  String httpHeaders = metadata.get("_response.headers_");

  if (StringUtils.isNotBlank(httpHeaders)) {
    output.write(httpHeaders.getBytes());
  } else {
    // change the record type to resource as we not have information about
    // the headers
    record.setType(WARCConstants.WARCRecordType.resource);
    record.setMimetype(content.getContentType());
  }

  output.write(getResponseContent().getBytes());

  record.setContentLength(output.size());
  record.setContentStream(new ByteArrayInputStream(output.toByteArray()));

  if (output.size() > 0) {
    // avoid generating a 0 sized record, as the webarchive library will
    // complain about it
    writer.writeRecord(record);
  }

  return record.getRecordId();
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:48,代码来源:CommonCrawlFormatWARC.java

示例8: setDate

import org.archive.util.DateUtils; //导入依赖的package包/类
public void setDate(Date date) {
	dateS = DateUtils.get14DigitDate(date);
	this.date = date; 
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:5,代码来源:ARCMetaData.java

示例9: setDateHeader

import org.archive.util.DateUtils; //导入依赖的package包/类
public void setDateHeader(String name, Date d) {
	String dv = DateUtils.getRFC1123Date(d);
	set(name, dv);
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:5,代码来源:HttpHeaders.java

示例10: addDateHeader

import org.archive.util.DateUtils; //导入依赖的package包/类
public void addDateHeader(String name, Date d) {
	String dv = DateUtils.getRFC1123Date(d);
	add(name, dv);
}
 
开发者ID:iipc,项目名称:webarchive-commons,代码行数:5,代码来源:HttpHeaders.java


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