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


Java DateData类代码示例

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


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

示例1: classForDataType

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
/**
 * map xforms data types to the Class that represents that data in a FormInstance
 * @param dataType
 * @return
 */
public static Class classForDataType (int dataType) {
	switch (dataType) {
	case Constants.DATATYPE_NULL: return StringData.class;
	case Constants.DATATYPE_TEXT: return StringData.class;
	case Constants.DATATYPE_INTEGER: return IntegerData.class;
	case Constants.DATATYPE_LONG: return LongData.class;
	case Constants.DATATYPE_DECIMAL: return DecimalData.class;
	case Constants.DATATYPE_BOOLEAN: return BooleanData.class;
	case Constants.DATATYPE_DATE: return DateData.class;
	case Constants.DATATYPE_TIME: return TimeData.class;
	case Constants.DATATYPE_DATE_TIME: return DateTimeData.class;
	case Constants.DATATYPE_CHOICE: return SelectOneData.class;
	case Constants.DATATYPE_CHOICE_LIST: return SelectMultiData.class;
	case Constants.DATATYPE_GEOPOINT: return GeoPointData.class;
	case Constants.DATATYPE_GEOSHAPE: return GeoShapeData.class;
	case Constants.DATATYPE_GEOTRACE: return GeoTraceData.class;
	default: return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:CompactInstanceWrapper.java

示例2: wrapIndeterminedObject

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
/**
 * Note: This method is a hack to fix the problem that we don't know what
 * data type we're using when we have a preloader. That should get fixed, 
 * and this method should be removed.
 * @param o
 * @return
 */
public static IAnswerData wrapIndeterminedObject(Object o) {
	if(o == null) {
		return null;
	}
	
	//TODO: Replace this all with an uncast data
	if(o instanceof String) {
		return new StringData((String)o);
	} else if(o instanceof Date) {
		return new DateData((Date)o);
	} else if (o instanceof Integer) {
		return new IntegerData((Integer)o);
	} else if (o instanceof Long) {
		return new LongData((Long)o);
	} else if (o instanceof Double) {
		return new DecimalData((Double)o);
	} else if(o instanceof List) {
		return new SelectMultiData((List<Selection>)o);
	} else if(o instanceof IAnswerData) {
		return (IAnswerData)o;
	}
	return new StringData(o.toString());
}
 
开发者ID:medic,项目名称:javarosa,代码行数:31,代码来源:PreloadUtils.java

示例3: testSetData

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
public void testSetData() {
	DateData data = new DateData(notToday);
	data.setValue(today);
	
	assertTrue("DateData did not set value properly. Maintained old value.", !(data.getValue().equals(notToday)));
	assertEquals("DateData did not properly set value ", data.getValue(), today);
	
	data.setValue(notToday);
	assertTrue("DateData did not set value properly. Maintained old value.", !(data.getValue().equals(today)));
	assertEquals("DateData did not properly reset value ", data.getValue(), notToday);
	
	Date temp = new Date(notToday.getTime());
	notToday.setTime(notToday.getTime() - 1324);
	
	assertEquals("DateData's value was mutated incorrectly", data.getValue(), temp);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:DateDataTests.java

示例4: setUp

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
public void setUp() throws Exception {
	super.setUp();
	stringData = new StringData(stringDataValue);
	stringElement.setValue(stringData);
	
	integerData = new IntegerData(integerDataValue);
	intElement.setValue(integerData);
	
	dateData = new DateData(dateDataValue); 
	dateElement.setValue(dateData);
	
	timeData = new TimeData(timeDataValue); 
	timeElement.setValue(timeData);
	
	serializer = new XFormAnswerDataSerializer();
}
 
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:XFormAnswerDataSerializerTest.java

示例5: wrapIndeterminedObject

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
/**
 * Note: This method is a hack to fix the problem that we don't know what
 * data type we're using when we have a preloader. That should get fixed,
 * and this method should be removed.
 */
public static IAnswerData wrapIndeterminedObject(Object o) {
    if (o == null) {
        return null;
    }

    //TODO: Replace this all with an uncast data
    if (o instanceof String) {
        return new StringData((String)o);
    } else if (o instanceof Date) {
        return new DateData((Date)o);
    } else if (o instanceof Integer) {
        return new IntegerData((Integer)o);
    } else if (o instanceof Long) {
        return new LongData((Long)o);
    } else if (o instanceof Double) {
        return new DecimalData((Double)o);
    } else if (o instanceof Vector) {
        return new SelectMultiData((Vector)o);
    } else if (o instanceof IAnswerData) {
        return (IAnswerData)o;
    }
    return new StringData(o.toString());
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:29,代码来源:PreloadUtils.java

示例6: testSetData

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
@Test
public void testSetData() {
    DateData data = new DateData(notToday);
    data.setValue(today);

    assertTrue("DateData did not set value properly. Maintained old value.", !(data.getValue().equals(notToday)));
    assertEquals("DateData did not properly set value ", data.getValue(), today);

    data.setValue(notToday);
    assertTrue("DateData did not set value properly. Maintained old value.", !(data.getValue().equals(today)));
    assertEquals("DateData did not properly reset value ", data.getValue(), notToday);

    Date temp = new Date(notToday.getTime());
    notToday.setTime(notToday.getTime() - 1324);

    assertEquals("DateData's value was mutated incorrectly", data.getValue(), temp);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:18,代码来源:DateDataTests.java

示例7: setUp

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
@BeforeClass
public static void setUp() {
    stringData = new StringData(stringDataValue);
    stringElement.setValue(stringData);

    integerData = new IntegerData(integerDataValue);
    intElement.setValue(integerData);

    dateData = new DateData(dateDataValue);
    dateElement.setValue(dateData);

    timeData = new TimeData(timeDataValue);
    timeElement.setValue(timeData);

    serializer = new XFormAnswerDataSerializer();
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:XFormAnswerDataSerializerTest.java

示例8: setAnswer

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
private void setAnswer() {

        if (mPrompt.getAnswerValue() != null) {
            DateTime ldt =
                new DateTime(((Date) ((DateData) mPrompt.getAnswerValue()).getValue()).getTime());
            mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(),
                mDateListener);
        } else {
            // create date widget with current time as of right now
            clearAnswer();
        }
    }
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:13,代码来源:DateWidget.java

示例9: getAnswer

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
@Override
public IAnswerData getAnswer() {
	if ( showCalendar ) {
		scrollView.clearChildFocus(mDatePicker);
	}
	clearFocus();
    DateTime ldt =
        new DateTime(mDatePicker.getYear(), (!showCalendar && hideMonth) ? 1 : mDatePicker.getMonth() + 1,
                (!showCalendar && (hideMonth || hideDay)) ? 1 : mDatePicker.getDayOfMonth(), 0, 0);
    // DateTime utc = ldt.withZone(DateTimeZone.forID("UTC"));
    return new DateData(ldt.toDate());
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:13,代码来源:DateWidget.java

示例10: unpackValue

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
public static Object unpackValue (IAnswerData val) {
	if (val == null) {
		return "";
	} else if (val instanceof UncastData) {
		return val.getValue();
	} else if (val instanceof IntegerData) {
		return new Double(((Integer)val.getValue()).doubleValue());
	} else if (val instanceof LongData) {
		return new Double(((Long)val.getValue()).doubleValue());
	} else if (val instanceof DecimalData) {
		return val.getValue();
	} else if (val instanceof StringData) {
		return val.getValue();
	} else if (val instanceof SelectOneData) {
		return ((Selection)val.getValue()).getValue();
	} else if (val instanceof SelectMultiData) {
		return (new XFormAnswerDataSerializer()).serializeAnswerData(val);
	} else if (val instanceof DateData) {
		return val.getValue();
	} else if (val instanceof BooleanData) {
		return val.getValue();
	} else if (val instanceof GeoPointData) {
		// we have no access fns that interact with double[4] arrays (the getValue() data type)...
		return val.getDisplayText();
	} else if (val instanceof GeoShapeData) {
		// we have no access fns that interact with GeoShape objects (the getValue() data type)...
		return val.getDisplayText();
	} else if (val instanceof GeoTraceData) {
		// we have no access fns that interact with GeoTrace objects (the getValue() data type)...
		return val.getDisplayText();
	} else {
		System.out.println("warning: unrecognized data type in xpath expr: " + val.getClass().getName());
		return val.getValue(); //is this a good idea?
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:36,代码来源:XPathPathExpr.java

示例11: canSerialize

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
public boolean canSerialize(IAnswerData data) {
	if (data instanceof StringData || data instanceof DateData || data instanceof TimeData ||
	    data instanceof SelectMultiData || data instanceof SelectOneData ||
	    data instanceof IntegerData || data instanceof DecimalData || data instanceof PointerAnswerData	||
	    data instanceof MultiPointerAnswerData ||
	    data instanceof GeoPointData || data instanceof GeoTraceData || data instanceof GeoShapeData ||
	    data instanceof LongData || data instanceof DateTimeData || data instanceof UncastData) {
		return true;
	} else {
		return false;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:13,代码来源:XFormAnswerDataSerializer.java

示例12: serializeAnswerData

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
public Object serializeAnswerData(IAnswerData data) {
	if (data instanceof StringData) {
		return serializeAnswerData((StringData)data);
	} else if (data instanceof SelectMultiData) {
		return serializeAnswerData((SelectMultiData)data);
	} else if (data instanceof SelectOneData) {
		return serializeAnswerData((SelectOneData)data);
	} else if (data instanceof IntegerData){
		return serializeAnswerData((IntegerData)data);
	} else if (data instanceof LongData){
		return serializeAnswerData((LongData)data);
	} else if (data instanceof DecimalData) {
		return serializeAnswerData((DecimalData)data);
	} else if (data instanceof DateData) {
		return serializeAnswerData((DateData)data);
	} else if (data instanceof TimeData) {
		return serializeAnswerData((TimeData)data);
	} else if (data instanceof PointerAnswerData) {
		return serializeAnswerData((PointerAnswerData)data);
	} else if (data instanceof MultiPointerAnswerData) {
		return serializeAnswerData((MultiPointerAnswerData)data);
	} else if (data instanceof GeoShapeData) {
           return serializeAnswerData((GeoShapeData)data);
	} else if (data instanceof GeoTraceData) {
           return serializeAnswerData((GeoTraceData)data);
	} else if (data instanceof GeoPointData) {
           return serializeAnswerData((GeoPointData)data);
       } else if (data instanceof DateTimeData) {
           return serializeAnswerData((DateTimeData)data);
       } else if (data instanceof BooleanData) {
           return serializeAnswerData((BooleanData)data);
       } else if (data instanceof UncastData) {
           return serializeAnswerData((UncastData)data);
       }

	return null;
}
 
开发者ID:medic,项目名称:javarosa,代码行数:38,代码来源:XFormAnswerDataSerializer.java

示例13: testGetData

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
public void testGetData() {
	DateData data = new DateData(today);
	assertEquals("DateData's getValue returned an incorrect date", data.getValue(), today);
	Date temp = new Date(today.getTime());
	today.setTime(1234);
	assertEquals("DateData's getValue was mutated incorrectly", data.getValue(), temp);
	
	Date rep = (Date)data.getValue();
	rep.setTime(rep.getTime() - 1000);
	
	assertEquals("DateData's getValue was mutated incorrectly", data.getValue(), temp);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:13,代码来源:DateDataTests.java

示例14: testNullData

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
public void testNullData() {
	boolean exceptionThrown = false;
	DateData data = new DateData();
	data.setValue(today);
	try { 
		data.setValue(null);
	} catch (NullPointerException e) {
		exceptionThrown = true;
	}
	assertTrue("DateData failed to throw an exception when setting null data", exceptionThrown);
	assertTrue("DateData overwrote existing value on incorrect input", data.getValue().equals(today));
}
 
开发者ID:medic,项目名称:javarosa,代码行数:13,代码来源:DateDataTests.java

示例15: getWidgetValue

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
protected IAnswerData getWidgetValue () {
    Date d = dateField().getDate();
    if(d == null) {
        return null;
    }
    if (dateTime) {
        return  new DateTimeData(d);
    } else {
        return new DateData(d);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:12,代码来源:DateEntryWidget.java


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