本文整理了Java中org.fujion.common.DateUtil.parseDate()
方法的一些代码示例,展示了DateUtil.parseDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.parseDate()
方法的具体详情如下:
包路径:org.fujion.common.DateUtil
类名称:DateUtil
方法名:parseDate
[英]Convert a string value to a date/time. Attempts to convert using the four locale-specific date formats (FULL, LONG, MEDIUM, SHORT). If these fail, looks to see if T+/-offset or N+/-offset is used.
TODO: probably we can make the "Java parse" portion a bit smarter by using a better variety of formats, maybe to catch Euro-style input as well.
TODO: probably we can add something like "t+d" or "t-y" as valid cases; in these scenarios, the coefficient was omitted and could be defaulted to 1.
[中]将字符串值转换为日期/时间。尝试使用四种特定于语言环境的日期格式(完整、长、中、短)进行转换。如果这些失败,查看是否使用T+/-偏移或N+/-偏移。
TODO:也许我们可以通过使用更好的格式使“Java解析”部分更智能一些,也许还可以捕获欧式输入。
TODO:也许我们可以添加“t+d”或“t-y”之类的内容作为有效案例;在这些场景中,系数被省略,可以默认为1。
代码示例来源:origin: org.fujion/fujion-common
/**
* Sets the end date.
*
* @param endDate The end date.
*/
private void setEndDate(String endDate) {
this.rawEndDate = endDate;
this.endDate = DateUtil.parseDate(endDate);
}
代码示例来源:origin: org.fujion/fujion-common
/**
* Parses an input value.
*
* @param value The value to parse.
* @return The resulting date value if successful.
* @throws ParseException Date parsing exception.
*/
public Date parse(String value) throws ParseException {
return parseDate(value, pattern);
}
}
代码示例来源:origin: org.fujion/fujion-core
@Override
protected Date _toValue(String value) {
return DateUtil.parseDate(value);
}
代码示例来源:origin: org.fujion/fujion-common
/**
* Sets the start date.
*
* @param startDate The start date.
*/
private void setStartDate(String startDate) {
this.rawStartDate = startDate;
this.startDate = DateUtil.parseDate(startDate);
}
代码示例来源:origin: org.fujion/fujion-core
@Override
protected Date _toValue(String value) {
return DateUtil.parseDate("01-Jan-1900 " + value);
}
代码示例来源:origin: org.hspconsortium.carewebframework/cwf-api-core
/**
* Returns a date value if the input is a valid date. Otherwise, returns null. Explicitly
* excludes some patterns that may successfully parse as a date.
*
* @param value Input to parse.
* @return Result of parsed input, or null if parsing unsuccessful.
*/
private Date parseDate(String value) {
if (StringUtils.isNumeric(value)) {
return null;
}
if (value.matches("^\\d+-\\d+$")) {
return null;
}
return DateUtil.parseDate(value);
}
代码示例来源:origin: org.carewebframework/org.carewebframework.api.core
/**
* Returns a date item associated with the specified item name.
*
* @param itemName Item name
* @return Date value
*/
public Date getDate(String itemName) {
try {
return DateUtil.parseDate(getItem(itemName));
} catch (Exception e) {
return null;
}
}
代码示例来源:origin: org.fujion/fujion-common
private void testDate(String value, Date expected, int threshold) {
Date actual = DateUtil.parseDate(value);
testDate(actual);
long diff = Math.abs(expected.getTime() - actual.getTime());
assertTrue("Difference exceeded threshold " + diff + " (" + threshold + ")", diff <= threshold);
}
代码示例来源:origin: org.fujion/fujion-common
private void testDate(Date date, boolean showTimezone, boolean ignoreTime) {
String text = DateUtil.formatDate(date, showTimezone, ignoreTime);
print(text);
Date date2 = DateUtil.parseDate(text);
String text2 = DateUtil.formatDate(date2, showTimezone, ignoreTime);
assertEquals(text, text2);
}
代码示例来源:origin: org.fujion/fujion-common
@Test
public void testDateUtil() {
testDate(now());
testDate(today());
testDate("T", today(), 0);
testDate("N", now(), 100);
testDate("T+30", DateUtil.addDays(today(), 30, false), 0);
testDate("N+30", DateUtil.addDays(now(), 30, false), 100);
testDate("T-4", DateUtil.addDays(today(), -4, false), 0);
testDate("T-50s", new Date(today().getTime() - 50000), 0);
testDate("N-50s", new Date(now().getTime() - 50000), 100);
testDate("T-50h", new Date(today().getTime() - 50 * 60 * 60 * 1000), 0);
testDate("T-50n", new Date(today().getTime() - 50 * 60 * 1000), 0);
Date date = DateUtil.parseDate("19880302");
testDate(date.toString(), date, 0);
}
代码示例来源:origin: org.hspconsortium.carewebframework/cwf-api-core
ssn.setValue("999-99-9999");
patient1.getIdentifier().add(ssn);
patient1.setBirthDate(DateUtil.parseDate("1958-07-27"));
Patient patient2 = new Patient();
patient2.setId("123");
ssn2.setValue("123-45-6789");
patient2.getIdentifier().add(ssn2);
patient2.setBirthDate(DateUtil.parseDate("1963-05-01"));
Object subscriber = new ContextChangeSubscriber(); // Create a patient context change subscriber
内容来源于网络,如有侵权,请联系作者删除!