蜂巢。(HIVE. SQL. Calculating time difference between string)
我有关于用户在线显示的数据。 在我的查询中,我只需要选择13:00:00到14:00:00之间的那些。
关于时间的数据行如下所示:
170214074534,这是YYMMDDHHMMSS - 2017年2月14日,07:45:34
你能帮我查询一下这部分吗?
我认为如果不将其转换为时间格式,应该更容易找到方法。 另一种方法似乎是忽略前6个符号并选择130000和135959之间的数据。
I have data about users showing up online. In my query I need to select only those between 13:00:00 and 14:00:00.
The data rows about time look like:
170214074534 where it is YYMMDDHHMMSS - 14 February 2017, 07:45:34
Can you help me with the query part please?
I think it should be easier to find a way without converting it to timedate format. Another way seems to be to ignore first 6 symbols and select data between 130000 and 135959.
原文:https://stackoverflow.com/questions/42823181
最满意答案
我不确定这是否是答案,但您需要先将响应信息设置为新类。 我用Gson库:
Gson gson = new Gson(); HttpResponse response = httpGetRequest("URL_ENDPOINT"); ResponseDTO responseDTO = gson.fromJson(prettyJsonResponse(response), ResponseDTO.class);
这是http get请求方法:
private HttpResponse httpGetRequest(String url) throws Exception { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(url); return client.execute(request); }
这是maven依赖:
<dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.2</version> </dependency>
prettyJsonResponse方法:
private String prettyJsonResponse(HttpResponse response) throws IOException{ StringBuffer result = new StringBuffer(); String line = ""; BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); while ((line = rd.readLine()) != null) { result.append(line); } return result.toString(); }
I am not sure if this is the answer, but you need set the response info to new class first. I use Gson library:
Gson gson = new Gson(); HttpResponse response = httpGetRequest("URL_ENDPOINT"); ResponseDTO responseDTO = gson.fromJson(prettyJsonResponse(response), ResponseDTO.class);
This is the http get request method:
private HttpResponse httpGetRequest(String url) throws Exception { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(url); return client.execute(request); }
This is the maven dependency:
<dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.2</version> </dependency>
prettyJsonResponse method:
private String prettyJsonResponse(HttpResponse response) throws IOException{ StringBuffer result = new StringBuffer(); String line = ""; BufferedReader rd = new BufferedReader( new InputStreamReader(response.getEntity().getContent())); while ((line = rd.readLine()) != null) { result.append(line); } return result.toString(); }
相关问答
更多-
您可以使用可编组源来完成Akka HTTP路由。 如果您不想使用自定义编组器,则始终可以使用Source[ByteString, _] 。 有关更多信息,请参阅文档 。 你的路线看起来像 get { val sampleExonRPKMs = exonRPKMService.getRPKMs(samples) val headers: String = ??? Source.single(headers).concat(Source(sampleExonRPKMs).map(_.toTSVLin ...
-
Apache无法写入文件(Apache Unable to Write to File)[2023-01-24]
尝试分配给www-data:nobody chown -R www-data:nobody * ,检查你的httpd.conf中的apache组。 至少验证/ var / html perms至775。 Try assigning to www-data:nobody chown -R www-data:nobody *, check apache group on your httpd.conf. Verify /var/html perms to 775 at least. -
你需要听每个html元素(例如图像) 这是样本 String uriString = request.getRequestLine().getUri(); Uri uri = Uri.parse(uriString); if (uri != null) { if (uri.toString().contains("mypic.jpg")) { HttpEntity entity = new EntityTemplate(new ContentProdu ...
-
让JSF打印出JSON字符串,好像它是一个JS变量。 Just let JSF print out the JSON string as if it's a JS variable.
-
angularjs nodejs从apache http server下载文件(angularjs nodejs download file from apache http server)[2022-09-23]
是的,你可以这么做。 Browser -> Node.JS Server -> Http Server -> Node.JS Server -> Browser使用请求模块,您可以在req和res之间传输文件。 https://www.npmjs.com/package/request#streaming 例: http.createServer(function (req, resp) { if (req.url === '/doodle.png') { r.get('http://googl ... -
您可以尝试设置以下参数: MAX_LINE_LENGTH = "http.connection.max-line-length" MAX_HEADER_COUNT = "http.connection.max-header-count" 我认为第一个的默认值是-1,这意味着没有限制。 You can try setting the following parameters: MAX_LINE_LENGTH = "http.connection.max-line-length" MAX_HEADER_COU ...
-
有几种方法,取决于你想如何处理响应 ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDownloadDestinationPath:@"/Users/Test/Desktop/cool.html"]; 使用setDownloadDestinationPath: set,它将保存到临时路径中,完成后,它会将其移动到您设置的downloadDestinationPath 。 或者您可以实现request:di ...
-
我不确定这是否是答案,但您需要先将响应信息设置为新类。 我用Gson库: Gson gson = new Gson(); HttpResponse response = httpGetRequest("URL_ENDPOINT"); ResponseDTO responseDTO = gson.fromJson(prettyJsonResponse(response), ResponseDTO.class); 这是http get请求方法: private Htt ...
-
这可能是由于v4.2 BasicClientConnectionManager中最近的一个错误影响了跨站点重定向。 见http://issues.apache.org/jira/browse/HTTPCLIENT-1193 。 根据维护者的说法,一个临时解决方法是使用SingleClientConnManager或PoolingClientConnectionManager。 也许是这样的: ClientConnectionManager connManager = new PoolingClientCon ...
-
一种方法是有两个循环:第一个用于响应头,读取直到你得到一个空行。 数据的第二个接收循环。 One way is to have two loops: The first for the response header, read until you get an empty line. The second receive loop for the data.