Skip to content

Instantly share code, notes, and snippets.

View jasonlvhit's full-sized avatar
💭
I may be slow to respond.

辣椒面 jasonlvhit

💭
I may be slow to respond.
View GitHub Profile
#include <set>
#include <stdio.h>
#include <sys/time.h>
double now()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec / 1000000.0;
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query