• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ConverterManager类的典型用法和代码示例

java 1次浏览

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

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

示例1: BaseInterval

点赞 3

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Constructs a time interval converting or copying from another object
 * that describes an interval.
 * 
 * @param interval  the time interval to copy
 * @param chrono  the chronology to use, null means let converter decide
 * @throws IllegalArgumentException if the interval is invalid
 */
protected BaseInterval(Object interval, Chronology chrono) {
    super();
    IntervalConverter converter = ConverterManager.getInstance().getIntervalConverter(interval);
    if (converter.isReadableInterval(interval, chrono)) {
        ReadableInterval input = (ReadableInterval) interval;
        iChronology = (chrono != null ? chrono : input.getChronology());
        iStartMillis = input.getStartMillis();
        iEndMillis = input.getEndMillis();
    } else if (this instanceof ReadWritableInterval) {
        converter.setInto((ReadWritableInterval) this, interval, chrono);
    } else {
        MutableInterval mi = new MutableInterval();
        converter.setInto(mi, interval, chrono);
        iChronology = mi.getChronology();
        iStartMillis = mi.getStartMillis();
        iEndMillis = mi.getEndMillis();
    }
    checkInterval(iStartMillis, iEndMillis);
}
 

开发者ID:redfish64,
项目名称:TinyTravelTracker,
代码行数:28,
代码来源:BaseInterval.java

示例2: BasePeriod

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Creates a new period based on another using the {@link ConverterManager}.
 *
 * @param period  the period to convert
 * @param type  which set of fields this period supports, null means use type from object
 * @param chrono  the chronology to use, null means ISO default
 * @throws IllegalArgumentException if period is invalid
 * @throws IllegalArgumentException if an unsupported field's value is non-zero
 */
protected BasePeriod(Object period, PeriodType type, Chronology chrono) {
    super();
    PeriodConverter converter = ConverterManager.getInstance().getPeriodConverter(period);
    type = (type == null ? converter.getPeriodType(period) : type);
    type = checkPeriodType(type);
    iType = type;
    if (this instanceof ReadWritablePeriod) {
        iValues = new int[size()];
        chrono = DateTimeUtils.getChronology(chrono);
        converter.setInto((ReadWritablePeriod) this, period, chrono);
    } else {
        iValues = new MutablePeriod(period, type, chrono).getValues();
    }
}
 

开发者ID:redfish64,
项目名称:TinyTravelTracker,
代码行数:24,
代码来源:BasePeriod.java

示例3: compare

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Compare two objects against only the range of date time fields as
 * specified in the constructor.
 * 
 * @param lhsObj  the first object,
 *      logically on the left of a < comparison, null means now
 * @param rhsObj  the second object,
 *      logically on the right of a < comparison, null means now
 * @return zero if order does not matter,
 *      negative value if lhsObj < rhsObj, positive value otherwise.
 * @throws IllegalArgumentException if either argument is not supported
 */
public int compare(Object lhsObj, Object rhsObj) {
    InstantConverter conv = ConverterManager.getInstance().getInstantConverter(lhsObj);
    Chronology lhsChrono = conv.getChronology(lhsObj, (Chronology) null);
    long lhsMillis = conv.getInstantMillis(lhsObj, lhsChrono);
    
    conv = ConverterManager.getInstance().getInstantConverter(rhsObj);
    Chronology rhsChrono = conv.getChronology(rhsObj, (Chronology) null);
    long rhsMillis = conv.getInstantMillis(rhsObj, rhsChrono);

    if (iLowerLimit != null) {
        lhsMillis = iLowerLimit.getField(lhsChrono).roundFloor(lhsMillis);
        rhsMillis = iLowerLimit.getField(rhsChrono).roundFloor(rhsMillis);
    }

    if (iUpperLimit != null) {
        lhsMillis = iUpperLimit.getField(lhsChrono).remainder(lhsMillis);
        rhsMillis = iUpperLimit.getField(rhsChrono).remainder(rhsMillis);
    }

    if (lhsMillis < rhsMillis) {
        return -1;
    } else if (lhsMillis > rhsMillis) {
        return 1;
    } else {
        return 0;
    }
}
 

开发者ID:redfish64,
项目名称:TinyTravelTracker,
代码行数:40,
代码来源:DateTimeComparator.java

示例4: testConstructor_badconverterObject

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object=null)
 */
public void testConstructor_badconverterObject() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        DateMidnight test = new DateMidnight(new Integer(0));
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L - DateTimeConstants.MILLIS_PER_HOUR, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestDateMidnight_Constructors.java

示例5: testConstructor_badconverterObject_DateTimeZone

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object, DateTimeZone)
 */
public void testConstructor_badconverterObject_DateTimeZone() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        DateMidnight test = new DateMidnight(new Integer(0), GregorianChronology.getInstance());
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L - DateTimeConstants.MILLIS_PER_HOUR, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestDateMidnight_Constructors.java

示例6: testConstructor_badconverterObject_Chronology

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object, Chronology)
 */
public void testConstructor_badconverterObject_Chronology() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        DateMidnight test = new DateMidnight(new Integer(0), GregorianChronology.getInstance());
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L - DateTimeConstants.MILLIS_PER_HOUR, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestDateMidnight_Constructors.java

示例7: testConstructor_badconverterObject

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object=null)
 */
public void testConstructor_badconverterObject() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        Instant test = new Instant(new Integer(0));
        assertEquals(ISOChronology.getInstanceUTC(), test.getChronology());
        assertEquals(0L, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestInstant_Constructors.java

示例8: testConstructor_badconverterObject

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object=null)
 */
public void testConstructor_badconverterObject() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        MutableDateTime test = new MutableDateTime(new Integer(0));
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestMutableDateTime_Constructors.java

示例9: testConstructor_badconverterObject_DateTimeZone

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object, DateTimeZone)
 */
public void testConstructor_badconverterObject_DateTimeZone() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        MutableDateTime test = new MutableDateTime(new Integer(0), GregorianChronology.getInstance());
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestMutableDateTime_Constructors.java

示例10: testConstructor_badconverterObject_Chronology

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object, Chronology)
 */
public void testConstructor_badconverterObject_Chronology() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        MutableDateTime test = new MutableDateTime(new Integer(0), GregorianChronology.getInstance());
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestMutableDateTime_Constructors.java

示例11: testConstructor_badconverterObject

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object=null)
 */
public void testConstructor_badconverterObject() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        DateTime test = new DateTime(new Integer(0));
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestDateTime_Constructors.java

示例12: testConstructor_badconverterObject_DateTimeZone

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object, DateTimeZone)
 */
public void testConstructor_badconverterObject_DateTimeZone() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        DateTime test = new DateTime(new Integer(0), GregorianChronology.getInstance());
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestDateTime_Constructors.java

示例13: testConstructor_badconverterObject_Chronology

点赞 2

import org.joda.time.convert.ConverterManager; //导入依赖的package包/类
/**
 * Test constructor (Object, Chronology)
 */
public void testConstructor_badconverterObject_Chronology() throws Throwable {
    try {
        ConverterManager.getInstance().addInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
        DateTime test = new DateTime(new Integer(0), GregorianChronology.getInstance());
        assertEquals(ISOChronology.getInstance(), test.getChronology());
        assertEquals(0L, test.getMillis());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(MockZeroNullIntegerConverter.INSTANCE);
    }
}
 

开发者ID:SpoonLabs,
项目名称:astor,
代码行数:14,
代码来源:TestDateTime_Constructors.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)