本文整理了Java中java.util.Date.parse()
方法的一些代码示例,展示了Date.parse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.parse()
方法的具体详情如下:
包路径:java.util.Date
类名称:Date
方法名:parse
[英]Returns the millisecond value of the date and time parsed from the specified String. Many date/time formats are recognized, including IETF standard syntax, i.e. Tue, 22 Jun 1999 12:16:00 GMT-0500
[中]返回从指定字符串解析的日期和时间的毫秒值。可以识别许多日期/时间格式,包括IETF标准语法,即1999年6月22日星期二12:16:00 GMT-0500
代码示例来源:origin: robovm/robovm
/**
* Constructs a new {@code Date} initialized to the date and time parsed from the
* specified String.
*
* @param string
* the String to parse.
*
* @deprecated Use {@link DateFormat} instead.
*/
@Deprecated
public Date(String string) {
milliseconds = parse(string);
}
代码示例来源:origin: robovm/robovm
.getMonths();
int value;
if (parse(text, weekdays) != -1) {/* empty */
} else if (month == -1 && (month = parse(text, months)) != -1) {/* empty */
} else if (text.equals("GMT") || text.equals("UT") || text.equals("UTC")) {
zone = true;
代码示例来源:origin: robovm/robovm
/**
* Returns the specified header value as a date in milliseconds since January
* 1, 1970 GMT. Returns the {@code defaultValue} if no such header field
* could be found.
*
* @param field
* the header field name whose value is needed.
* @param defaultValue
* the default value if no field has been found.
* @return the value of the specified header field as a date in
* milliseconds.
*/
@SuppressWarnings("deprecation")
public long getHeaderFieldDate(String field, long defaultValue) {
String date = getHeaderField(field);
if (date == null) {
return defaultValue;
}
try {
return Date.parse(date); // TODO: use HttpDate.parse()
} catch (Exception e) {
return defaultValue;
}
}
代码示例来源:origin: sannies/mp4parser
@SuppressWarnings("deprecation")
public void setMediaCreateDate(String date) {
try {
setMediaCreateDate(new Date(Date.parse(date))); //Deprecated, but also the easiest way to do this quickly
} catch (IllegalArgumentException e) {
throw new RuntimeException("Unable to parse date '" + date + "'", e);
}
}
代码示例来源:origin: sannies/mp4parser
@SuppressWarnings("deprecation")
public void setMediaModificationDate(String date) {
setMediaModificationDate(new Date(Date.parse(date))); //Deprecated, but also the easiest way to do this quickly
}
代码示例来源:origin: konsoletyper/teavm
@SuppressWarnings("deprecation")
public long getHeaderFieldDate(String field, long defaultValue) {
String date = getHeaderField(field);
if (date == null) {
return defaultValue;
}
try {
return Date.parse(date);
} catch (Exception e) {
return defaultValue;
}
}
代码示例来源:origin: spotbugs/spotbugs
@Override
protected void handleOptionWithArgument(String option, String argument) throws IOException {
if ("-name".equals(option)) {
revisionName = argument;
} else if ("-projectName".equals(option)) {
projectName = argument;
} else if ("-suppress".equals(option)) {
exclusionFilterFile = argument;
} else if ("-timestamp".equals(option)) {
revisionTimestamp = Date.parse(argument);
} else if ("-source".equals(option)) {
sourcePaths.add(argument);
} else if ("-lastVersion".equals(option)) {
lastVersion = argument;
} else if ("-findSource".equals(option)) {
searchSourcePaths.add(argument);
} else {
throw new IllegalArgumentException("Can't handle option " + option);
}
}
代码示例来源:origin: spotbugs/spotbugs
* Integer.parseInt(val.substring(0, val.length() - 7));
} else {
time = Date.parse(val);
代码示例来源:origin: wangdan/AisenWeiBo
createCal.setTimeInMillis(Long.parseLong(time));
} catch (Exception e) {
createCal.setTimeInMillis(Date.parse(time));
createCal.setTimeInMillis(Date.parse(time));
代码示例来源:origin: intel-hadoop/HiBench
rand = new Random();
date = new Date();
dateRange = Date.parse("Tue 1 May 2012 00:00:00"); // random date range
dateForm = new SimpleDateFormat("yyyy-MM-dd");
代码示例来源:origin: apache/cloudstack
String ifModifiedSince = t.getRequestHeaders().getFirst("If-Modified-Since");
if (ifModifiedSince != null) {
long d = Date.parse(ifModifiedSince);
if (d + 1000 >= lastModified) {
Headers hds = t.getResponseHeaders();
代码示例来源:origin: stackoverflow.com
Caused by: java.lang.IllegalArgumentException
04-20 09:21:32.553: ERROR/AndroidRuntime(838): at java.util.Date.parse(Date.java:447)
04-20 09:21:32.553: ERROR/AndroidRuntime(838): at java.util.Date.<init>(Date.java:157)
04-20 09:21:32.553: ERROR/AndroidRuntime(838): at winterwell.jtwitter.Twitter$Status.<init>(Twitter.java:659)
04-20 09:21:32.553: ERROR/AndroidRuntime(838): at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:3231)
代码示例来源:origin: MobiVM/robovm
/**
* Constructs a new {@code Date} initialized to the date and time parsed from the
* specified String.
*
* @param string
* the String to parse.
*
* @deprecated Use {@link DateFormat} instead.
*/
@Deprecated
public Date(String string) {
milliseconds = parse(string);
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Constructs a new {@code Date} initialized to the date and time parsed from the
* specified String.
*
* @param string
* the String to parse.
*
* @deprecated Use {@link DateFormat} instead.
*/
@Deprecated
public Date(String string) {
milliseconds = parse(string);
}
代码示例来源:origin: com.google.code.maven-play-plugin.com.google.code.morphia/morphia
@SuppressWarnings("deprecation")
@Override
public
Object decode(Class targetClass, Object val, MappedField optionalExtraInfo) throws MappingException {
if (val == null) return null;
if (val instanceof Date)
return val;
if (val instanceof Number)
return new Date(((Number)val).longValue());
return new Date(Date.parse(val.toString())); // good luck
}
}
代码示例来源:origin: stackoverflow.com
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (view.getId() == R.id.swimm_date) {
DateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
TextView tv = (TextView)view;
tv.setText(sdf.format(java.util.Date.parse(cursor.getString(columnIndex))));
return true;
}
代码示例来源:origin: org.jboss.jsfunit/jboss-jsfunit-core
@Override
public long getDateHeader(String name)
{
String header = getHeader(name);
if (header == null) return -1;
return Date.parse(header);
}
代码示例来源:origin: net.java.truevfs/truevfs-driver-http
@Override
@SuppressWarnings("deprecation")
public long getTime(Access type) {
if (WRITE != type)
return UNKNOWN;
try {
final String field = getHeaderField("last-modified");
if (null != field)
return Date.parse(field);
} catch (IllegalArgumentException | IOException ex) {
}
return UNKNOWN;
}
代码示例来源:origin: oVirt/ovirt-engine
@Override
public void formatValue(String fieldName, Pair<String, String> pair, boolean caseSensitive) {
if (CREATION_DATE.equals(fieldName)) {
Date tmp = new Date(Date.parse(StringHelper.trim(pair.getSecond(), '\'')));
pair.setSecond(StringFormat.format("'%1$s'", tmp));
} else {
super.formatValue(fieldName, pair, caseSensitive);
}
}
}
代码示例来源:origin: EvoSuite/evosuite
@SuppressWarnings("deprecation")
public static long parse(String s) {
Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, CaptureUtil.loadClass("java/util/Date"), "parse", "(Ljava/lang/String;)J", new Object[] {s});
long ret = java.util.Date.parse(s);
Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, CaptureUtil.loadClass("java/util/Date"), ret);
return ret;
}
内容来源于网络,如有侵权,请联系作者删除!