Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 740745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:33:05+00:00 2026-05-14T08:33:05+00:00

I do not know the reason why am i getting same values of different

  • 0

I do not know the reason why am i getting same values of different JSON date values.
Here is my code for parsing date values in JSON date format:

package com.jsondate.parsing;

import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class JSONDateParsing extends Activity {
    /** Called when the activity is first created. */
    String myString;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


        TextView tv = new TextView(this);
        //Date d = (new Date(1266029455L));
        //Date d = (new Date(1266312467L));
        Date d = (new Date(1266036226L));


        //String s = d.getDate() + "-" + d.getMonth() + "-" + d.getYear() + d.getHours() + d.getMinutes() + d.getSeconds();
       // SimpleDateFormat sdf=new SimpleDateFormat("yyyy MMM dd @ hh:mm aa");
        //Toast.makeText(this, d.toString(), Toast.LENGTH_SHORT);
        Log.e("Value:", d.toString());
        myString = d.toString();
        String []words = myString.split(" ");

        for(int i = 0;i < words.length; i++)
            Log.e("Value:", words[i]);

        myString = words[2] + "-" + words[1] + "-" + words[5] + " " + words[3];

        tv.setText(myString);
        setContentView(tv);


    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:33:05+00:00Added an answer on May 14, 2026 at 8:33 am

    As far as I know, there is no standard way of representing a date in JSON. It looks as though what you are receiving is an integral value representing the number of seconds that have elapsed since the epoch of January 1, 1970, 00:00:00 GMT. This is somewhat different than what the Date(long date) constructor is expecting. The constructor is expecting milliseconds since the epoch. You need to multiply the values from the JSON by 1000 to use them correctly with Date.

    long jsonDate = 1266036226L;
    Date date = new Date(jsonDate * 1000);
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss");
    String stringDate = dateFormat.format(date);
    

    Here are the different representations for the examples that you have given. Do they correspond with what you are expecting?

    • 1266029455 <==> 12-Feb-2010 09:50:55
    • 1266312467 <==> 16-Feb-2010 04:27:47
    • 1266036226 <==> 12-Feb-2010 11:43:46
    • 1266072180 <==> 13-Feb-2010 09:43:46

    Note that the default behavior of SimpleDateFormat is to use the local time zone. In my case this is GMT-0500. A different time zone can be specified by calling the setTimeZone method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know why but for some reason I am not able to refer
I do not know what I am doing when it comes to JSON. So
I do not not know much about Regex, I want to try parsing sting
I do not know if this is possible, but here goes. And working with
I am getting following exception from webservices: com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character ((CTRL-CHAR, code 15)) I
For some reason I’m getting an undefined variable on the view and not quite
I do not know how to ask this question. So I will just give
I do not know why my google markers are not showing. I am using
EPD python does not know to look for the Ubuntu repository python so installing
I do not know javascript right now but I am planning on learning it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.