Search code examples
yahoo-finance

yahoo api timezone


how can i receive a specific time zone for the received date-time from yahoo api?

and what is the default time zone?

http://hk.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDHKD=x

http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDHKD=x

the received time is the same

private String GetRequest() throws ClientProtocolException, IOException{
    HttpClient httpClient = new DefaultHttpClient();
    HttpContext localContext = new BasicHttpContext();
    HttpGet httpGet = new HttpGet("http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDHKD=x");
    HttpResponse response = httpClient.execute(httpGet, localContext);

    BufferedReader reader = new BufferedReader(
        new InputStreamReader(
          response.getEntity().getContent()
        )
      );

    String line;
    while ((line = reader.readLine()) != null) {
         String[] RowData = line.split(",");
         String value = RowData[1];//value = qoute
         String date = RowData[2].replaceAll("\"", "");
         String time = RowData[3].replaceAll("\"", "");
         tvDateTimeValue.setText(date+"\t"+time);
         return value;
    }
    return "";
}

Solution

  • It looks like the value is always given in UTC. That seems entirely reasonable to me. In particular, it's never ambiguous, and never subject to historical changes etc.

    If you want to display the data in a particular time zone, perform the translation yourself. (I'd give sample code, but you haven't specified how you're accessing the API, e.g. which language you're using.)