本文整理汇总了Java中org.joda.time.chrono.ISOChronology类的典型用法代码示例。如果您正苦于以下问题:Java ISOChronology类的具体用法?Java ISOChronology怎么用?Java ISOChronology使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ISOChronology类属于org.joda.time.chrono包,在下文中一共展示了ISOChronology类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRewriteDateToMatchAll
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
public void testRewriteDateToMatchAll() throws IOException {
String fieldName = randomAsciiOfLengthBetween(1, 20);
RangeQueryBuilder query = new RangeQueryBuilder(fieldName) {
@Override
protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException {
return Relation.WITHIN;
}
};
DateTime queryFromValue = new DateTime(2015, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
DateTime queryToValue = new DateTime(2016, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
query.from(queryFromValue);
query.to(queryToValue);
QueryShardContext queryShardContext = createShardContext();
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, instanceOf(RangeQueryBuilder.class));
RangeQueryBuilder rewrittenRange = (RangeQueryBuilder) rewritten;
assertThat(rewrittenRange.fieldName(), equalTo(fieldName));
assertThat(rewrittenRange.from(), equalTo(null));
assertThat(rewrittenRange.to(), equalTo(null));
}
示例2: testRewriteDateToMatchAllWithTimezoneAndFormat
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
public void testRewriteDateToMatchAllWithTimezoneAndFormat() throws IOException {
String fieldName = randomAsciiOfLengthBetween(1, 20);
RangeQueryBuilder query = new RangeQueryBuilder(fieldName) {
@Override
protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException {
return Relation.WITHIN;
}
};
DateTime queryFromValue = new DateTime(2015, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
DateTime queryToValue = new DateTime(2016, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
query.from(queryFromValue);
query.to(queryToValue);
query.timeZone(randomFrom(DateTimeZone.getAvailableIDs()));
query.format("yyyy-MM-dd");
QueryShardContext queryShardContext = createShardContext();
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, instanceOf(RangeQueryBuilder.class));
RangeQueryBuilder rewrittenRange = (RangeQueryBuilder) rewritten;
assertThat(rewrittenRange.fieldName(), equalTo(fieldName));
assertThat(rewrittenRange.from(), equalTo(null));
assertThat(rewrittenRange.to(), equalTo(null));
assertThat(rewrittenRange.timeZone(), equalTo(null));
assertThat(rewrittenRange.format(), equalTo(null));
}
示例3: testRewriteDateToMatchNone
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
public void testRewriteDateToMatchNone() throws IOException {
String fieldName = randomAsciiOfLengthBetween(1, 20);
RangeQueryBuilder query = new RangeQueryBuilder(fieldName) {
@Override
protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException {
return Relation.DISJOINT;
}
};
DateTime queryFromValue = new DateTime(2015, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
DateTime queryToValue = new DateTime(2016, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
query.from(queryFromValue);
query.to(queryToValue);
QueryShardContext queryShardContext = createShardContext();
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, instanceOf(MatchNoneQueryBuilder.class));
}
示例4: testRewriteDateToSame
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
public void testRewriteDateToSame() throws IOException {
String fieldName = randomAsciiOfLengthBetween(1, 20);
RangeQueryBuilder query = new RangeQueryBuilder(fieldName) {
@Override
protected MappedFieldType.Relation getRelation(QueryRewriteContext queryRewriteContext) throws IOException {
return Relation.INTERSECTS;
}
};
DateTime queryFromValue = new DateTime(2015, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
DateTime queryToValue = new DateTime(2016, 1, 1, 0, 0, 0, ISOChronology.getInstanceUTC());
query.from(queryFromValue);
query.to(queryToValue);
QueryShardContext queryShardContext = createShardContext();
QueryBuilder rewritten = query.rewrite(queryShardContext);
assertThat(rewritten, sameInstance(query));
}
示例5: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
Assertion assertion = (Assertion) samlObject;
if (Assertion.ID_ATTRIB_NAME.equals(attribute.getLocalName())) {
assertion.setID(attribute.getValue());
} else if (Assertion.ISSUER_ATTRIB_NAME.equals(attribute.getLocalName())) {
assertion.setIssuer(attribute.getValue());
} else if (Assertion.ISSUEINSTANT_ATTRIB_NAME.equals(attribute.getLocalName())
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
assertion.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (Assertion.MINORVERSION_ATTRIB_NAME.equals(attribute.getLocalName())) {
if (attribute.getValue().equals("0")) {
assertion.setVersion(SAMLVersion.VERSION_10);
} else {
assertion.setVersion(SAMLVersion.VERSION_11);
}
} else {
super.processAttribute(samlObject, attribute);
}
}
示例6: fetchMetadata
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected byte[] fetchMetadata() throws MetadataProviderException {
try {
validateMetadataFile(metadataFile);
DateTime metadataUpdateTime = new DateTime(metadataFile.lastModified(), ISOChronology.getInstanceUTC());
if (getLastRefresh() == null || getLastUpdate() == null || metadataUpdateTime.isAfter(getLastRefresh())) {
return inputstreamToByteArray(new FileInputStream(metadataFile));
}
return null;
} catch (IOException e) {
String errMsg = "Unable to read metadata file " + metadataFile.getAbsolutePath();
log.error(errMsg, e);
throw new MetadataProviderException(errMsg, e);
}
}
示例7: doFilter
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
public void doFilter(XMLObject metadata) throws FilterException {
DateTime validUntil = getValidUntil(metadata);
if (validUntil == null) {
throw new FilterException("Metadata did not include a validUntil attribute");
}
DateTime now = new DateTime(ISOChronology.getInstanceUTC());
if (maxValidityInterval > 0 && validUntil.isAfter(now)) {
long validityInterval = validUntil.getMillis() - now.getMillis();
if (validityInterval > maxValidityInterval) {
throw new FilterException("Metadata's validity interval, " + validityInterval
+ "ms, is larger than is allowed, " + maxValidityInterval + "ms.");
}
}
}
示例8: computeNextRefreshDelay
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/**
* Computes the delay until the next refresh time based on the current metadata's expiration time and the refresh
* interval floor.
*
* @param expectedExpiration the time when the metadata is expected to expire and need refreshing
*
* @return delay, in milliseconds, until the next refresh time
*/
protected long computeNextRefreshDelay(DateTime expectedExpiration) {
long now = new DateTime(ISOChronology.getInstanceUTC()).getMillis();
long expireInstant = 0;
if (expectedExpiration != null) {
expireInstant = expectedExpiration.toDateTime(ISOChronology.getInstanceUTC()).getMillis();
}
long refreshDelay = (long) ((expireInstant - now) * getRefreshDelayFactor());
// if the expiration time was null or the calculated refresh delay was less than the floor
// use the floor
if (refreshDelay < getMinRefreshDelay()) {
refreshDelay = getMinRefreshDelay();
}
return refreshDelay;
}
示例9: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
AffiliationDescriptor descriptor = (AffiliationDescriptor) samlObject;
if (attribute.getLocalName().equals(AffiliationDescriptor.OWNER_ID_ATTRIB_NAME)) {
descriptor.setOwnerID(attribute.getValue());
} else if (attribute.getLocalName().equals(AffiliationDescriptor.ID_ATTRIB_NAME)) {
descriptor.setID(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else if (attribute.getLocalName().equals(TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
descriptor.setValidUntil(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(CacheableSAMLObject.CACHE_DURATION_ATTRIB_NAME)) {
descriptor.setCacheDuration(XMLHelper.durationToLong(attribute.getValue()));
} else {
QName attribQName = XMLHelper.getNodeQName(attribute);
if (attribute.isId()) {
descriptor.getUnknownAttributes().registerID(attribQName);
}
descriptor.getUnknownAttributes().put(attribQName, attribute.getValue());
}
}
示例10: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
EntityDescriptor entityDescriptor = (EntityDescriptor) samlObject;
if (attribute.getLocalName().equals(EntityDescriptor.ENTITY_ID_ATTRIB_NAME)) {
entityDescriptor.setEntityID(attribute.getValue());
} else if (attribute.getLocalName().equals(EntityDescriptor.ID_ATTRIB_NAME)) {
entityDescriptor.setID(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else if (attribute.getLocalName().equals(TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
entityDescriptor.setValidUntil(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(CacheableSAMLObject.CACHE_DURATION_ATTRIB_NAME)) {
entityDescriptor.setCacheDuration(XMLHelper.durationToLong(attribute.getValue()));
} else {
QName attribQName = XMLHelper.getNodeQName(attribute);
if (attribute.isId()) {
entityDescriptor.getUnknownAttributes().registerID(attribQName);
}
entityDescriptor.getUnknownAttributes().put(attribQName, attribute.getValue());
}
}
示例11: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
EntitiesDescriptor entitiesDescriptor = (EntitiesDescriptor) samlObject;
if (attribute.getLocalName().equals(EntitiesDescriptor.ID_ATTRIB_NAME)) {
entitiesDescriptor.setID(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else if (attribute.getLocalName().equals(TimeBoundSAMLObject.VALID_UNTIL_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
entitiesDescriptor.setValidUntil(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(CacheableSAMLObject.CACHE_DURATION_ATTRIB_NAME)) {
entitiesDescriptor.setCacheDuration(new Long(XMLHelper.durationToLong(attribute.getValue())));
} else if (attribute.getLocalName().equals(EntitiesDescriptor.NAME_ATTRIB_NAME)) {
entitiesDescriptor.setName(attribute.getValue());
} else {
super.processAttribute(samlObject, attribute);
}
}
示例12: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
Assertion assertion = (Assertion) samlObject;
if (attribute.getLocalName().equals(Assertion.VERSION_ATTRIB_NAME)) {
assertion.setVersion(SAMLVersion.valueOf(attribute.getValue()));
} else if (attribute.getLocalName().equals(Assertion.ISSUE_INSTANT_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
assertion.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(Assertion.ID_ATTRIB_NAME)) {
assertion.setID(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else {
super.processAttribute(samlObject, attribute);
}
}
示例13: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
RequestAbstractType req = (RequestAbstractType) samlObject;
if (attribute.getLocalName().equals(RequestAbstractType.VERSION_ATTRIB_NAME)) {
req.setVersion(SAMLVersion.valueOf(attribute.getValue()));
} else if (attribute.getLocalName().equals(RequestAbstractType.ID_ATTRIB_NAME)) {
req.setID(attribute.getValue());
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
} else if (attribute.getLocalName().equals(RequestAbstractType.ISSUE_INSTANT_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
req.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(RequestAbstractType.DESTINATION_ATTRIB_NAME)) {
req.setDestination(attribute.getValue());
} else if (attribute.getLocalName().equals(RequestAbstractType.CONSENT_ATTRIB_NAME)) {
req.setConsent(attribute.getValue());
} else {
super.processAttribute(samlObject, attribute);
}
}
示例14: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
LogoutRequest req = (LogoutRequest) samlObject;
if (attribute.getLocalName().equals(LogoutRequest.REASON_ATTRIB_NAME)) {
req.setReason(attribute.getValue());
} else if (attribute.getLocalName().equals(LogoutRequest.NOT_ON_OR_AFTER_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
req.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else {
super.processAttribute(samlObject, attribute);
}
}
示例15: processAttribute
import org.joda.time.chrono.ISOChronology; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
SubjectConfirmationData subjectCD = (SubjectConfirmationData) samlObject;
if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_BEFORE_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
subjectCD.setNotBefore(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(SubjectConfirmationData.NOT_ON_OR_AFTER_ATTRIB_NAME)
&& !DatatypeHelper.isEmpty(attribute.getValue())) {
subjectCD.setNotOnOrAfter(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
} else if (attribute.getLocalName().equals(SubjectConfirmationData.RECIPIENT_ATTRIB_NAME)) {
subjectCD.setRecipient(attribute.getValue());
} else if (attribute.getLocalName().equals(SubjectConfirmationData.IN_RESPONSE_TO_ATTRIB_NAME)) {
subjectCD.setInResponseTo(attribute.getValue());
} else if (attribute.getLocalName().equals(SubjectConfirmationData.ADDRESS_ATTRIB_NAME)) {
subjectCD.setAddress(attribute.getValue());
} else {
QName attribQName = XMLHelper.getNodeQName(attribute);
if (attribute.isId()) {
subjectCD.getUnknownAttributes().registerID(attribQName);
}
subjectCD.getUnknownAttributes().put(attribQName, attribute.getValue());
}
}