本文整理了Java中org.geotools.feature.type.DateUtil.serializeDateTime()
方法的一些代码示例,展示了DateUtil.serializeDateTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateUtil.serializeDateTime()
方法的具体详情如下:
包路径:org.geotools.feature.type.DateUtil
类名称:DateUtil
方法名:serializeDateTime
[英]Serialize time to general dateTime text. This method is provided for backward compatibility. It generates the dateTime text without the trailing 'Z' to indicate UTC.
[中]将时间序列化为常规日期时间文本。提供此方法是为了向后兼容。它生成日期时间文本,但不带表示UTC的尾随“Z”。
代码示例来源:origin: geotools/geotools
/**
* Serialize time to general dateTime text. This method is provided for backward compatibility.
* It generates the dateTime text without the trailing 'Z' to indicate UTC.
*
* @param time time to be converted, as milliseconds from January 1, 1970
* @return converted dateTime text
* @throws IllegalArgumentException on conversion error
*/
public static String serializeDateTime(long time) throws IllegalArgumentException {
return serializeDateTime(time, false);
}
代码示例来源:origin: geotools/geotools
/**
* Serialize date to general dateTime text. Date values are formatted in W3C XML Schema standard
* format as CCYY-MM-DDThh:mm:ss, with optional leading sign and trailing seconds decimal, as
* necessary.
*
* @param date date to be converted
* @return converted dateTime text
* @throws IllegalArgumentException on conversion error
*/
public static String serializeDateTime(Date date) throws IllegalArgumentException {
long time = date.getTime();
time += TimeZone.getDefault().getOffset(time);
return serializeDateTime(time, false);
}
代码示例来源:origin: geotools/geotools
return serializeDateTime(stamp.getTime(), false) + '.' + digits + 'Z';
} else {
return serializeDateTime(stamp.getTime(), true);
代码示例来源:origin: geotools/geotools
public void testJavaUtilDate() {
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(2007, 3, 1, 1, 15);
Date time = cal.getTime();
String dateTime = DateUtil.serializeDateTime(time);
assertEquals("2007-04-01T01:15:00", dateTime);
String date = DateUtil.serializeDate(time);
assertEquals("2007-04-01", date);
}
代码示例来源:origin: geotools/geotools
else if (value instanceof java.sql.Time)
text = DateUtil.serializeSqlTime((java.sql.Time) value);
else text = DateUtil.serializeDateTime((Date) value);
contentHandler.characters(text.toCharArray(), 0, text.length());
} else {
代码示例来源:origin: org.geoserver/gs-wfs
@Override
public String format(Object att) {
return prepCSVField(DateUtil.serializeDateTime((Date) att));
}
}
代码示例来源:origin: org.geotools/gt-main
/**
* Serialize time to general dateTime text. This method is provided for
* backward compatibility. It generates the dateTime text without the
* trailing 'Z' to indicate UTC.
*
* @param time time to be converted, as milliseconds from January 1, 1970
*
* @return converted dateTime text
*
* @throws IllegalArgumentException on conversion error
*/
public static String serializeDateTime(long time)
throws IllegalArgumentException {
return serializeDateTime(time, false);
}
代码示例来源:origin: org.geotools/gt2-main
/**
* Serialize time to general dateTime text. This method is provided for
* backward compatibility. It generates the dateTime text without the
* trailing 'Z' to indicate UTC.
*
* @param time time to be converted, as milliseconds from January 1, 1970
*
* @return converted dateTime text
*
* @throws IllegalArgumentException on conversion error
*/
public static String serializeDateTime(long time)
throws IllegalArgumentException {
return serializeDateTime(time, false);
}
代码示例来源:origin: org.geotools/gt-main
/**
* Serialize date to general dateTime text. Date values are formatted in
* W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss, with optional
* leading sign and trailing seconds decimal, as necessary.
*
* @param date date to be converted
*
* @return converted dateTime text
*
* @throws IllegalArgumentException on conversion error
*/
public static String serializeDateTime(Date date)
throws IllegalArgumentException {
long time = date.getTime();
time += TimeZone.getDefault().getOffset(time);
return serializeDateTime(time, false);
}
代码示例来源:origin: org.geotools/gt2-main
/**
* Serialize date to general dateTime text. Date values are formatted in
* W3C XML Schema standard format as CCYY-MM-DDThh:mm:ss, with optional
* leading sign and trailing seconds decimal, as necessary.
*
* @param date date to be converted
*
* @return converted dateTime text
*
* @throws IllegalArgumentException on conversion error
*/
public static String serializeDateTime(Date date)
throws IllegalArgumentException {
long time = date.getTime();
time += TimeZone.getDefault().getOffset(time);
return serializeDateTime(time, false);
}
代码示例来源:origin: org.geotools/gt-main
return serializeDateTime(stamp.getTime(), false) + '.' + digits
+ 'Z';
} else {
return serializeDateTime(stamp.getTime(), true);
代码示例来源:origin: org.geotools/gt2-main
return serializeDateTime(stamp.getTime(), false) + '.' + digits
+ 'Z';
} else {
return serializeDateTime(stamp.getTime(), true);
代码示例来源:origin: org.geoserver/gs-wfs
private String formatToString(Object att, NumberFormat coordFormatter) {
String value;
if (att instanceof Number) {
// don't allow scientific notation in the output, as OpenOffice won't
// recognize that as a number
value = coordFormatter.format(att);
} else if (att instanceof Date) {
// serialize dates in ISO format
if (att instanceof java.sql.Date)
value = DateUtil.serializeSqlDate((java.sql.Date) att);
else if (att instanceof java.sql.Time)
value = DateUtil.serializeSqlTime((java.sql.Time) att);
else value = DateUtil.serializeDateTime((Date) att);
} else {
// everything else we just "toString"
value = att.toString();
}
return value;
}
代码示例来源:origin: org.geoserver/gs-wms
@Override
/**
* Formats the dimension default value for the capabilities file as ISO 8601 DateTime for TIME
* and as a number for ELEVATION. Assumes that getDefaultValue returns a single value, classes
* handling ranges have to override this method
*/
public String getCapabilitiesRepresentation(
ResourceInfo resource, String dimensionName, DimensionInfo dimensionInfo) {
String retval = null;
if (dimensionName.equals(ResourceInfo.TIME)) {
Date dateValue =
(Date) getDefaultValue(resource, dimensionName, dimensionInfo, Date.class);
if (dateValue == null) {
return DimensionDefaultValueSetting.TIME_CURRENT;
}
retval = DateUtil.serializeDateTime(dateValue.getTime(), true);
} else if (dimensionName.equals(ResourceInfo.ELEVATION)) {
Number numberValue =
(Number) getDefaultValue(resource, dimensionName, dimensionInfo, Number.class);
if (numberValue == null) {
return "0";
}
retval = numberValue.toString();
} else {
Object value = getDefaultValue(resource, dimensionName, dimensionInfo, Object.class);
retval = value.toString();
}
return retval;
}
}
代码示例来源:origin: org.geoserver.community/gs-geogig
@Override
protected Component getComponentForProperty(
final String id,
@SuppressWarnings("rawtypes") IModel<LogEvent> itemModel,
Property<LogEvent> property) {
LogEvent item = (LogEvent) itemModel.getObject();
if (property == LogEventProvider.SEVERITY) {
Severity severity = item.getSeverity();
PackageResourceReference iconRef = SEVERITY_ICONS.get(severity);
return new Icon(id, iconRef);
}
if (property == LogEventProvider.REPOSITORY) {
return repositoryLink(id, item);
}
if (property == LogEventProvider.TIMESTAMP) {
return new Label(id, DateUtil.serializeDateTime(item.getTimestamp()));
}
if (property == LogEventProvider.MESSAGE) {
return messageLink(id, item);
}
return new Label(id, String.valueOf(property.getPropertyValue(item)));
}
代码示例来源:origin: org.geoserver.extension/monitor-core
public void testGetAllCSVQuery() throws Exception {
RequestResource.CSVFormat format = new RequestResource.CSVFormat(
new String[]{"id", "path", "startTime"}, monitor);
ByteArrayOutputStream out = new ByteArrayOutputStream();
format.toRepresentation(new Query()).write(out);
BufferedReader in = new BufferedReader(new InputStreamReader(
new ByteArrayInputStream(out.toByteArray())));
String line = in.readLine();
assertEquals("id,path,startTime", line);
Iterator<RequestData> it = monitor.getDAO().getRequests().iterator();
while((line = in.readLine()) != null) {
assertTrue(it.hasNext());
RequestData data = it.next();
String expected = data.getId() + "," + data.getPath() + "," +
DateUtil.serializeDateTime(data.getStartTime());
assertEquals(expected, line);
}
assertFalse(it.hasNext());
}
代码示例来源:origin: org.geoserver.extension/monitor-core
@Test
public void testGetAllCSV() throws Exception {
RequestResource.CSVFormat format = new RequestResource.CSVFormat(
new String[]{"id", "path", "startTime"}, monitor);
ByteArrayOutputStream out = new ByteArrayOutputStream();
format.toRepresentation(monitor.getDAO().getRequests()).write(out);
BufferedReader in = new BufferedReader(new InputStreamReader(
new ByteArrayInputStream(out.toByteArray())));
String line = in.readLine();
assertEquals("id,path,startTime", line);
Iterator<RequestData> it = monitor.getDAO().getRequests().iterator();
while((line = in.readLine()) != null) {
assertTrue(it.hasNext());
RequestData data = it.next();
String expected = data.getId() + "," + data.getPath() + "," +
DateUtil.serializeDateTime(data.getStartTime());
assertEquals(expected, line);
}
assertFalse(it.hasNext());
}
代码示例来源:origin: org.geoserver.extension/gs-monitor-core
@Test
public void testGetAllCSV() throws Exception {
MockHttpServletResponse response =
getAsServletResponse(
RestBaseController.ROOT_PATH
+ "/monitor/requests.csv?fields=id;path;startTime");
assertEquals(200, response.getStatus());
// System.out.println(response.getContentAsString());
BufferedReader in =
new BufferedReader(
new InputStreamReader(
new ByteArrayInputStream(response.getContentAsByteArray())));
String line = in.readLine();
assertEquals("id,path,startTime", line);
Iterator<RequestData> it = monitor.getDAO().getRequests().iterator();
while ((line = in.readLine()) != null) {
assertTrue(it.hasNext());
RequestData data = it.next();
String expected =
data.getId()
+ ","
+ data.getPath()
+ ","
+ DateUtil.serializeDateTime(data.getStartTime());
assertEquals(expected, line);
}
assertFalse(it.hasNext());
}
代码示例来源:origin: org.geoserver.extension/monitor-core
requests = true;
String expected = "id,path,startTime\n12345,/foo," + DateUtil.serializeDateTime(startTime);
assertEquals(expected, readEntry(zin));
代码示例来源:origin: org.geoserver.extension/gs-monitor-core
"id,path,startTime\n12345,/foo," + DateUtil.serializeDateTime(startTime);
assertEquals(expected, readEntry(zin));
} else if ("body.txt".equals(entry.getName())) {
内容来源于网络,如有侵权,请联系作者删除!