• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DateData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getAnswerTemplate

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


示例17: 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 DateTimeData) {
        return val.getValue();
    } else if (val instanceof BooleanData) {
        return val.getValue();
    } else if (val instanceof GeoPointData) {
        return val.uncast().getString();
    } else {
        System.out.println("warning: unrecognized data type in xpath expr: " + val.getClass().getName());

        //TODO: Does this mess up any of our other plans?
        return val.uncast().getString();
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:33,代码来源:XPathPathExpr.java


示例18: preloadDate

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
/**
 * Preloads a DateData object for the preload type 'date'
 *
 * @param preloadParams The parameters determining the date
 * @return A preload date value if the parameters can be parsed,
 * null otherwise
 */
private IAnswerData preloadDate(String preloadParams) {
    Date d = null;
    if (preloadParams.equals("today")) {
        d = new Date();
    } else if (preloadParams.substring(0, 11).equals("prevperiod-")) {
        String[] params = DataUtil.splitOnDash(preloadParams.substring(11));

        try {
            String type = params[0];
            String start = params[1];

            boolean beginning;
            if (params[2].equals("head")) beginning = true;
            else if (params[2].equals("tail")) beginning = false;
            else throw new RuntimeException();

            boolean includeToday;
            if (params.length >= 4) {
                if (params[3].equals("x")) includeToday = true;
                else if (params[3].equals("")) includeToday = false;
                else throw new RuntimeException();
            } else {
                includeToday = false;
            }

            int nAgo;
            if (params.length >= 5) {
                nAgo = Integer.parseInt(params[4]);
            } else {
                nAgo = 1;
            }

            d = DateUtils.getPastPeriodDate(new Date(), type, start, beginning, includeToday, nAgo);
        } catch (Exception e) {
            throw new IllegalArgumentException("invalid preload params for preload mode 'date'");
        }
    }
    return new DateData(d);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:47,代码来源:QuestionPreloader.java


示例19: 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 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:dimagi,项目名称:commcare-j2me,代码行数:32,代码来源:XFormAnswerDataSerializer.java


示例20: testGetData

import org.javarosa.core.model.data.DateData; //导入依赖的package包/类
@Test
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:dimagi,项目名称:commcare-j2me,代码行数:14,代码来源:DateDataTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java S31PacketWindowProperty类代码示例发布时间:2022-05-22
下一篇:
Java CodingSchemeRenderingList类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap