本文整理了Java中org.activityinfo.model.type.time.LocalDate.parse()
方法的一些代码示例,展示了LocalDate.parse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.parse()
方法的具体详情如下:
包路径:org.activityinfo.model.type.time.LocalDate
类名称:LocalDate
方法名:parse
[英]Obtains an instance of LocalDate from a text string such as 2007-12-03.
The following format is accepted in ASCII:
{Year}-{MonthOfYear}-{DayOfMonth}
The year has between 4 and 10 digits with values from MIN_YEAR to MAX_YEAR. If there are more than 4 digits then the year must be prefixed with the plus symbol. Zero and negative years are not allowed, and will cause an exception in the LocalDate constructor.
The month-of-year has 2 digits with values from 1 to 12.
The day-of-month has 2 digits with values from 1 to 31 appropriate to the month.
[中]从文本字符串(如2007-12-03)获取LocalDate的实例。
ASCII接受以下格式:
{Year}-{MonthOfYear}-{DayOfMonth}
年份有4到10位数字,数值从最小年份到最大年份。如果数字超过4位,则年份必须以加号作为前缀。不允许零年和负年,这将导致LocalDate构造函数中出现异常。
一年中的月份有2位数字,其值从1到12。
月份的日期有2位数字,数值范围为1到31,与月份相符。
代码示例来源:origin: bedatadriven/activityinfo
@Override
public LocalDate toFieldValue(Object hrdValue) {
String stringValue = (String) hrdValue;
return LocalDate.parse(stringValue);
}
};
代码示例来源:origin: bedatadriven/activityinfo
@Override
public LocalDate getValue(String dataPeriod) {
return LocalDate.parse(dataPeriod);
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public PeriodValue parseString(String string) {
return LocalDate.parse(string);
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public LocalDate render(int rowIndex) {
assert view != null : "updateColumnSet() has not been called";
String text = view.getString(rowIndex);
if(text == null) {
return null;
}
return LocalDate.parse(text);
}
代码示例来源:origin: bedatadriven/activityinfo
protected int apply(String string) {
return apply(LocalDate.parse(string));
}
代码示例来源:origin: bedatadriven/activityinfo
public static LocalDateInterval fromJson(JsonValue object) {
return new LocalDateInterval(
LocalDate.parse(object.getString("start")),
LocalDate.parse(object.getString("end")));
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public PeriodValue fromSubFormKey(RecordRef ref) {
String subRecordId = ref.getRecordId().asString();
String dateKey = subRecordId.substring(subRecordId.length() - 10);
return LocalDate.parse(dateKey);
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public Date render(int rowIndex) {
assert view != null : "updateColumnSet() has not been called";
String text = view.getString(rowIndex);
if(text == null) {
return null;
}
return LocalDate.parse(text).atMidnightInMyTimezone();
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public ColumnView columnApply(int numRows, List<ColumnView> arguments) {
if(arguments.size() != 2) {
throw new FormulaSyntaxException("YEARFRAC() requires two arguments");
}
ColumnView startView = arguments.get(0);
ColumnView endView = arguments.get(1);
double[] result = new double[numRows];
for (int i = 0; i < numRows; i++) {
String start = startView.getString(i);
String end = endView.getString(i);
if(start == null || end == null) {
result[i] = Double.NaN;
} else {
result[i] = compute(LocalDate.parse(start), LocalDate.parse(end));
}
}
return new DoubleArrayColumnView(result);
}
}
代码示例来源:origin: bedatadriven/activityinfo
private void check(String startDateString, String endDateString, double expectedFrac) {
LocalDate startDate = LocalDate.parse(startDateString);
LocalDate endDate = LocalDate.parse(endDateString);
double frac = YearFracFunction.compute(startDate, endDate);
double diff = Math.abs(frac - expectedFrac);
if(diff > 0.001) {
throw new AssertionError(String.format("Expected YEARFRAC(%s, %s) = %10.5f, but was %10.5f",
startDateString,
endDateString,
expectedFrac,
frac));
}
}
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public LocalDate parseJsonValue(JsonValue value) {
if(value.isJsonObject()) {
value = value.get("value");
}
return LocalDate.parse(value.asString());
}
代码示例来源:origin: bedatadriven/activityinfo
private FieldValue parseDate(JsonValue value) {
if(value.isJsonObject()) {
JsonValue object = value;
if(object.get("type").asString().equals("LocalDate")) {
return LocalDate.parse(object.get("value").asString());
}
}
return null;
}
代码示例来源:origin: bedatadriven/activityinfo
@Override
public ColumnView columnApply(int numRows, List<ColumnView> arguments) {
ColumnView dateView = arguments.get(0);
ColumnView daysView = arguments.get(1);
String[] result = new String[dateView.numRows()];
for (int i = 0; i < dateView.numRows(); i++) {
LocalDate date = LocalDate.parse(dateView.getString(i));
int days = (int)daysView.getDouble(i);
result[i] = date.plusDays(days).toString();
}
return new StringArrayColumnView(result);
}
}
代码示例来源:origin: bedatadriven/activityinfo
static boolean isSnoozed(AccountStatus status, String snoozePrefix) {
try {
Storage storage = Storage.getLocalStorageIfSupported();
if(storage == null) {
return false;
}
String accountSnooze = storage.getItem(snoozePrefix + status.getUserAccountId());
if(accountSnooze == null) {
return false;
}
LocalDate snoozeDate = LocalDate.parse(accountSnooze);
LocalDate today = new LocalDate();
if(today.before(snoozeDate)) {
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
}
内容来源于网络,如有侵权,请联系作者删除!