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 6854395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:37:41+00:00 2026-05-27T01:37:41+00:00

i am using Gson to convert json to Java class…the Type of firstLogin is

  • 0

i am using Gson to convert json to Java class…the Type of firstLogin is java.util.Date

public static void main(String[] args) {

     String lineString="{\"email\":\"sadas\",\"faith\":121,\"qq\":211,\"account\":2412,\"userName\":\"asda\",\"firstLogin\":1321362590000,\"uid\":1}";
     Gson gson=new Gson();
User user=gson.fromJson(lineString, User.class);
    System.out.println(user.getFirstLogin());
}

Exception:

Exception in thread "main" com.google.gson.JsonSyntaxException: 1321362590000
    at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:78)
    at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:63)
    at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:38)
    at com.google.gson.internal.bind.TypeAdapters$19$1.read(TypeAdapters.java:462)
    at com.google.gson.internal.bind.TypeAdapters$19$1.read(TypeAdapters.java:466)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:86)
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:170)
    at com.google.gson.Gson.fromJson(Gson.java:720)
    at com.google.gson.Gson.fromJson(Gson.java:686)
    at com.google.gson.Gson.fromJson(Gson.java:636)
    at com.google.gson.Gson.fromJson(Gson.java:608)
    at gsontest.GsonTest.main(GsonTest.java:22)
Caused by: java.text.ParseException: Unparseable date: "1321362590000"
    at java.text.DateFormat.parse(DateFormat.java:357)
    at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:76)
    ... 11 more
Java Result: 1

how to fix the problem …Thanks

  • 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-27T01:37:41+00:00Added an answer on May 27, 2026 at 1:37 am

    firstLogin has a long type in your json, so get it as a long variable from JSON and create a new Date using Date(long milliseconds) constructor.

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

Sidebar

Related Questions

I'm using Gson to convert Json to an object in Java. Json that i'm
I'm using Google's GSON Library to convert JSON data to Java objects. The issue
I'm using Gson to convert a Java object to Json. One of the object's
I am trying to convert an object into JSON using the GSON library on
I am using GSON to parse a Java bean and pass the JSON string
I'm using JSON with Gson package for java. I have an object where there
I am using gson to parse json into java beans. For the API I
Hi I have the following class and need to convert the incoming Json using
im trying to convert a json object to a string by using gson here
I'm using GSON on my Java EE server to provide some json to views.

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.