本文整理汇总了Java中com.sun.syndication.io.impl.DateParser类的典型用法代码示例。如果您正苦于以下问题:Java DateParser类的具体用法?Java DateParser怎么用?Java DateParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateParser类属于com.sun.syndication.io.impl包,在下文中一共展示了DateParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
public Module parse(Element dcRoot) {
boolean foundSomething = false;
SampleModule fm = new SampleModuleImpl();
Element e = dcRoot.getChild("bar", SAMPLE_NS);
if (e != null) {
foundSomething = true;
fm.setBar(e.getText());
}
List eList = dcRoot.getChildren("foo", SAMPLE_NS);
if (eList.size() > 0) {
foundSomething = true;
fm.setFoos(parseFoos(eList));
}
e = dcRoot.getChild("date", SAMPLE_NS);
if (e != null) {
foundSomething = true;
fm.setDate(DateParser.parseDate(e.getText()));
}
return (foundSomething) ? fm : null;
}
示例2: generate
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
public void generate(Module module, Element element) {
SampleModule fm = (SampleModule)module;
if (fm.getBar() != null) {
element.addContent(generateSimpleElement("bar", fm.getBar()));
}
List foos = fm.getFoos();
for (int i = 0; i < foos.size(); i++) {
element.addContent(generateSimpleElement("foo",foos.get(i).toString()));
}
if (fm.getDate() != null) {
element.addContent(
generateSimpleElement("date", DateParser.formatW3CDateTime(fm.getDate())));
}
}
示例3: _testEntry
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
protected void _testEntry(int i) throws Exception {
List items = getCachedSyndFeed().getEntries();
SyndEntry entry = (SyndEntry) items.get(i);
assertProperty(entry.getTitle(),"feed.entry["+i+"].title");
assertProperty(entry.getTitleEx().getValue(),"feed.entry["+i+"].title");
assertEquals("text",entry.getTitleEx().getType());
assertEquals(entry.getLink(),"http://example.com/blog/entry" + (i + 1));
assertEquals(((SyndEnclosure)entry.getEnclosures().get(0)).getUrl(),"http://example.com/blog/enclosure"+(i+1)+".gif");
assertProperty(entry.getAuthor(),"feed.entry["+i+"].author.name");
Date d = DateParser.parseW3CDateTime("2000-0"+(i+1)+"-01T01:00:00Z");
assertEquals(entry.getPublishedDate(),d);
assertProperty(entry.getDescription().getValue(),"feed.entry["+i+"].summary");
assertProperty(((SyndContent)entry.getContents().get(0)).getValue(),"feed.entry["+i+"].content[0]");
assertEquals(1, ((List)entry.getForeignMarkup()).size());
SyndLink slink = (SyndLink)entry.getLinks().get(2);
assertTrue(slink.getHref().startsWith("tag:"));
}
示例4: _testItem
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
protected void _testItem(int i) throws Exception {
super._testItem(i);
List items = getCachedSyndFeed().getEntries();
SyndEntry entry = (SyndEntry) items.get(i);
Date d = DateParser.parseRFC822("Mon, 0"+(i+1)+" Jan 2001 00:00:00 GMT");
assertEquals(entry.getPublishedDate(),d);
_testDescriptionType(entry,i);
}
示例5: _testDCModule
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
protected void _testDCModule(DCModule dc,String prefix,boolean isEntry,int index) throws Exception {
assertNotNull(dc);
assertProperty(dc.getTitle(),prefix+"dc:title");
assertProperty(dc.getCreator(),prefix+"dc:creator"); // Convenience method
assertProperty(((DCSubject)dc.getSubjects().get(0)).getValue(),prefix+"dc:subject[0]");
String taxo0 = ((DCSubject)dc.getSubjects().get(0)).getTaxonomyUri();
if (taxo0!=null) {
assertProperty(taxo0,prefix+"dc:subject[0].taxo:topic^resource");
}
assertProperty(((DCSubject)dc.getSubjects().get(1)).getValue(),prefix+"dc:subject[1]");
String taxo1 = ((DCSubject)dc.getSubjects().get(1)).getTaxonomyUri();
if (taxo1!=null) {
assertProperty(taxo1,prefix+"dc:subject[1].taxo:topic^resource");
}
assertProperty(dc.getDescription(),prefix+"dc:description");
assertProperty(dc.getPublisher(),prefix+"dc:publisher");
assertProperty((String)dc.getContributors().get(0),prefix+"dc:contributor[0]");
assertProperty((String)dc.getContributors().get(1),prefix+"dc:contributor[1]");
Date date = DateParser.parseW3CDateTime("2000-0"+(index+1)+"-01T00:00:00Z");
assertEquals(dc.getDate(),date);
assertProperty(dc.getType(),prefix+"dc:type");
assertProperty(dc.getFormat(),prefix+"dc:format");
assertProperty(dc.getIdentifier(),prefix+"dc:identifier");
assertProperty(dc.getSource(),prefix+"dc:source");
assertProperty(dc.getLanguage(),prefix+"dc:language");
assertProperty(dc.getRelation(),prefix+"dc:relation");
assertProperty(dc.getCoverage(),prefix+"dc:coverage");
if (isEntry) {
assertProperty(dc.getRights(),prefix+"dc:rights");
}
else {
assertProperty(dc.getRights(),prefix+"copyright"); // in header is convenience method
}
}
示例6: testFeedSyModule
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
public void testFeedSyModule() throws Exception {
SyModule sy = (SyModule) getCachedSyndFeed().getModule(SyModule.URI);
assertNotNull(sy);
assertEquals(sy.getUpdatePeriod(),SyModule.HOURLY);
assertEquals(sy.getUpdateFrequency(),100);
Date date = DateParser.parseW3CDateTime("2001-01-01T01:00+00:00");
assertEquals(sy.getUpdateBase(),date);
}
示例7: _testEntry
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
protected void _testEntry(int i) throws Exception {
List items = getCachedSyndFeed().getEntries();
SyndEntry entry = (SyndEntry) items.get(i);
assertProperty(entry.getTitle(),"feed.entry["+i+"].title");
assertProperty(entry.getLink(),"feed.entry["+i+"].link^href");
assertProperty(entry.getAuthor(),"feed.entry["+i+"].author.name");
Date d = DateParser.parseW3CDateTime("2000-0"+(i+1)+"-01T00:00:00Z");
assertEquals(entry.getPublishedDate(),d);
assertProperty(entry.getDescription().getValue(),"feed.entry["+i+"].summary");
assertProperty(((SyndContent)entry.getContents().get(0)).getValue(),"feed.entry["+i+"].content[0]");
assertProperty(((SyndContent)entry.getContents().get(1)).getValue(),"feed.entry["+i+"].content[1]");
}
示例8: _testEntry
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
protected void _testEntry(int i) throws Exception {
List items = getCachedSyndFeed().getEntries();
SyndEntry entry = (SyndEntry) items.get(i);
assertProperty(entry.getTitle(),"feed.entry["+i+"].title");
assertEquals(entry.getLink(),"http://example.com/blog/entry" + (i + 1));
assertProperty(entry.getAuthor(),"feed.entry["+i+"].author.name");
Date d = DateParser.parseW3CDateTime("2000-0"+(i+1)+"-01T01:00:00Z");
assertEquals(entry.getPublishedDate(),d);
assertProperty(entry.getDescription().getValue(),"feed.entry["+i+"].summary");
assertProperty(((SyndContent)entry.getContents().get(0)).getValue(),"feed.entry["+i+"].content[0]");
}
示例9: _testDCModule
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
protected void _testDCModule(DCModule dc,String prefix) throws Exception {
assertNotNull(dc);
assertProperty(dc.getTitle(),prefix+"dc:title");
assertProperty(dc.getCreator(),prefix+"dc:creator");
assertProperty(((DCSubject)dc.getSubjects().get(0)).getValue(),prefix+"dc:subject[0]");
String taxo0 = ((DCSubject)dc.getSubjects().get(0)).getTaxonomyUri();
if (taxo0!=null) {
assertProperty(taxo0,prefix+"dc:subject[0].taxo:topic^resource");
}
assertProperty(((DCSubject)dc.getSubjects().get(1)).getValue(),prefix+"dc:subject[1]");
String taxo1 = ((DCSubject)dc.getSubjects().get(1)).getTaxonomyUri();
if (taxo1!=null) {
assertProperty(taxo1,prefix+"dc:subject[1].taxo:topic^resource");
}
assertProperty(dc.getDescription(),prefix+"dc:description");
assertProperty(dc.getPublisher(),prefix+"dc:publisher");
assertProperty((String)dc.getContributors().get(0),prefix+"dc:contributor[0]");
assertProperty((String)dc.getContributors().get(1),prefix+"dc:contributor[1]");
Date date = DateParser.parseW3CDateTime("2001-01-01T00:00+00:00");
assertEquals(dc.getDate(),date);
assertProperty(dc.getType(),prefix+"dc:type");
assertProperty(dc.getFormat(),prefix+"dc:format");
assertProperty(dc.getIdentifier(),prefix+"dc:identifier");
assertProperty(dc.getSource(),prefix+"dc:source");
assertProperty(dc.getLanguage(),prefix+"dc:language");
assertProperty(dc.getRelation(),prefix+"dc:relation");
assertProperty(dc.getCoverage(),prefix+"dc:coverage");
assertProperty(dc.getRights(),prefix+"dc:rights");
}
示例10: testChannelSyModule
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
public void testChannelSyModule() throws Exception {
SyModule sy = (SyModule) getCachedSyndFeed().getModule(SyModule.URI);
assertNotNull(sy);
assertEquals(sy.getUpdatePeriod(),SyModule.HOURLY);
assertEquals(sy.getUpdateFrequency(),100);
Date date = DateParser.parseW3CDateTime("2001-01-01T01:00+00:00");
assertEquals(sy.getUpdateBase(),date);
}
示例11: toString
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
private String toString(Object o) {
if (o != null) {
if (o instanceof Date) {
return DateParser.formatRFC822((Date)o);
} else {
return o.toString();
}
}
return "";
}
示例12: parseDateAttribute
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
private Date parseDateAttribute(Element childElement, String attrName) {
Attribute dateAttribute = childElement.getAttribute(attrName);
Date date = null;
if (dateAttribute != null) {
// SSE spec requires the timezone to be 'GMT'
// admittedly, this is a bit heavy-handed
String dateAttr = dateAttribute.getValue().trim();
return DateParser.parseRFC822(dateAttr);
}
return date;
}
示例13: _testDCModule
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
protected void _testDCModule(DCModule dc,String prefix) throws Exception {
assertNotNull(dc);
assertProperty((String)dc.getTitles().get(0), prefix + "dc:title[0]");
assertProperty((String)dc.getTitles().get(1), prefix + "dc:title[1]");
assertProperty((String)dc.getCreators().get(0), prefix + "dc:creator[0]");
assertProperty((String)dc.getCreators().get(1), prefix + "dc:creator[1]");
assertProperty(((DCSubject)dc.getSubjects().get(0)).getValue(), prefix + "dc:subject[0]");
String taxo0 = ((DCSubject)dc.getSubjects().get(0)).getTaxonomyUri();
if (taxo0 != null) {
assertProperty(taxo0, prefix + "dc:subject[0].taxo:topic^resource");
}
assertProperty(((DCSubject)dc.getSubjects().get(1)).getValue(), prefix + "dc:subject[1]");
String taxo1 = ((DCSubject)dc.getSubjects().get(1)).getTaxonomyUri();
if (taxo1 != null) {
assertProperty(taxo1, prefix + "dc:subject[1].taxo:topic^resource");
}
assertProperty((String)dc.getDescriptions().get(0), prefix + "dc:description[0]");
assertProperty((String)dc.getDescriptions().get(1), prefix + "dc:description[1]");
assertProperty((String)dc.getPublishers().get(0), prefix + "dc:publisher[0]");
assertProperty((String)dc.getPublishers().get(1), prefix + "dc:publisher[1]");
assertProperty((String)dc.getContributors().get(0),prefix + "dc:contributor[0]");
assertProperty((String)dc.getContributors().get(1),prefix + "dc:contributor[1]");
Date date = DateParser.parseW3CDateTime("2001-01-01T00:00+00:00");
assertEquals((Date)dc.getDates().get(0), date);
assertEquals((Date)dc.getDates().get(1), date);
assertProperty((String)dc.getTypes().get(0), prefix + "dc:type[0]");
assertProperty((String)dc.getTypes().get(1), prefix +"dc:type[1]");
assertProperty((String)dc.getFormats().get(0), prefix + "dc:format[0]");
assertProperty((String)dc.getFormats().get(1), prefix + "dc:format[1]");
assertProperty((String)dc.getIdentifiers().get(0), prefix + "dc:identifier[0]");
assertProperty((String)dc.getIdentifiers().get(1), prefix + "dc:identifier[1]");
assertProperty((String)dc.getSources().get(0), prefix + "dc:source[0]");
assertProperty((String)dc.getSources().get(1), prefix + "dc:source[1]");
assertProperty((String)dc.getLanguages().get(0), prefix + "dc:language[0]");
assertProperty((String)dc.getLanguages().get(1), prefix + "dc:language[1]");
assertProperty((String)dc.getRelations().get(0), prefix + "dc:relation[0]");
assertProperty((String)dc.getRelations().get(1), prefix + "dc:relation[1]");
assertProperty((String)dc.getCoverages().get(0), prefix + "dc:coverage[0]");
assertProperty((String)dc.getCoverages().get(1), prefix + "dc:coverage[1]");
assertProperty((String)dc.getRightsList().get(0), prefix + "dc:rights[0]");
assertProperty((String)dc.getRightsList().get(1), prefix + "dc:rights[1]");
}
示例14: testPublishedDate
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
public void testPublishedDate() throws Exception {
Date d = DateParser.parseW3CDateTime("2000-01-01T00:00:00Z");
assertEquals(getCachedSyndFeed().getPublishedDate(),d);
}
示例15: testParseRFC822
import com.sun.syndication.io.impl.DateParser; //导入依赖的package包/类
public void testParseRFC822() {
Calendar cal = new GregorianCalendar();
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
// four-digit year
String sDate = "Tue, 19 Jul 2005 23:00:51 GMT";
cal.setTime(DateParser.parseRFC822(sDate));
assertEquals(2005, cal.get(Calendar.YEAR));
assertEquals(6, cal.get(Calendar.MONTH)); // month is zero-indexed
assertEquals(19, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(3, cal.get(Calendar.DAY_OF_WEEK));
assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(0, cal.get(Calendar.MINUTE));
assertEquals(51, cal.get(Calendar.SECOND));
// two-digit year
sDate = "Tue, 19 Jul 05 23:00:51 GMT";
cal.setTime(DateParser.parseRFC822(sDate));
assertEquals(2005, cal.get(Calendar.YEAR));
assertEquals(6, cal.get(Calendar.MONTH)); // month is zero-indexed
assertEquals(19, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(3, cal.get(Calendar.DAY_OF_WEEK));
assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(0, cal.get(Calendar.MINUTE));
assertEquals(51, cal.get(Calendar.SECOND));
//RFC822
sDate = "Tue, 19 Jul 2005 23:00:51 GMT";
assertNotNull(DateParser.parseDate(sDate));
//RFC822
sDate = "Tue, 19 Jul 05 23:00:51 GMT";
assertNotNull(DateParser.parseDate(sDate));
//W3C
sDate = "2000-01-01T00:00:00Z";
assertNotNull(DateParser.parseDate(sDate));
//EXTRA
sDate = "18:10 2000/10/10";
assertNotNull(DateParser.parseDate(sDate));
//INVALID
sDate = "X20:10 2000-10-10";
assertNull(DateParser.parseDate(sDate));
}