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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:49:37+00:00 2026-06-06T23:49:37+00:00

Here i am getting problem while submitting grid to java i am getting date

  • 0

Here i am getting problem while submitting grid to java i am getting date parsing error. how to resolve this error. Please help me. Below is my response.

This is response

{"gridData":[{"id":170,"afs":5,"date":"04-22-2011","qty":12,"quantity":11,"shift":"A","sourceLocation":"Office","time":"12:00:00 AM"},{"id":171,"afs":6,"date":"04-22-2011","qty":12,"quantity":11,"shift":"B","sourceLocation":"Office","time":"12:00:00 AM"},{"id":172,"afs":7,"date":"04-22-2011","qty":12,"quantity":11,"shift":"C","sourceLocation":"Office","time":"12:00:00 AM"},{"id":173,"afs":8,"date":"04-22-2011","qty":12,"quantity":11,"shift":"A","sourceLocation":"Office","time":"12:00:00 AM"},{"id":174,"afs":9,"date":"04-22-2011","qty":12,"quantity":11,"shift":"B","sourceLocation":"Office","time":"12:00:00 AM"},{"id":175,"afs":10,"date":"04-22-2011","qty":12,"quantity":11,"shift":"C","sourceLocation":"Office","time":"12:00:00 AM"},{"id":176,"afs":11,"date":"04-22-2011","qty":12,"quantity":11,"shift":"A","sourceLocation":"Office","time":"12:00:00 AM"},{"id":177,"afs":12,"date":"04-22-2011","qty":12,"quantity":11,"shift":"B","sourceLocation":"Office","time":"12:00:00 AM"},{"id":178,"afs":13,"date":"04-22-2011","qty":12,"quantity":11,"shift":"C","sourceLocation":"Office","time":"12:00:00 AM"},{"id":179,"afs":14,"date":"04-22-2011","qty":12,"quantity":11,"shift":"A","sourceLocation":"Office","time":"12:00:00 AM"},{"id":180,"afs":15,"date":"04-22-2011","qty":12,"quantity":11,"shift":"B","sourceLocation":"Office","time":"12:00:00 AM"},{"id":181,"afs":16,"date":"04-22-2011","qty":12,"quantity":11,"shift":"C","sourceLocation":"Office","time":"12:00:00 AM"},{"id":182,"afs":17,"date":"04-22-2011","qty":12,"quantity":11,"shift":"A","sourceLocation":"Office","time":"12:00:00 AM"}],"success":true}

this is Grid column config

columns: [
            {
                xtype: 'gridcolumn',
                dataIndex: 'afs',
                text: 'AFS'
            },
            {
                xtype: 'gridcolumn',
                dataIndex: 'date',
                text: 'Date',
                flex :1
            }]

This is my POJO class config for date

@JsonSerialize(using=JsonDateSerializer.class)
public Date getDate() {
    return this.date;
}

This is my Controller class

 public@ResponseBody String saveGridData(HttpServletRequest request,@RequestParam("grid") String gridData){
    System.out.println("Group Name :"+request.getParameter("groupName"));
    JSONPObject json = new JSONPObject("encode", gridData);
    System.out.println(gridData);
    NewSand[] newSands =    getJsonString(gridData, NewSand[].class);
    for(NewSand newSand: newSands){
        System.out.println("Shift --> " + newSand.getShift());
    }
    return "true";
}

private static <T> T getJsonString(String json,  Class<T> type) throws JsonParseException{

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.serializeNulls();
    JsonSerializer<Date> ser = new JsonSerializer<Date>() {
          public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext 
                     context) {
            return src == null ? null : new JsonPrimitive(src.getTime());
          }
        };

        JsonDeserializer<Date> deser = new JsonDeserializer<Date>() {
          public Date deserialize(JsonElement json, Type typeOfT,JsonDeserializationContext context) throws JsonParseException {
            return json == null ? null : new Date(json.getAsLong());
          }
        };
        Gson gson = gsonBuilder.registerTypeAdapter(Date.class, ser).registerTypeAdapter(Date.class, deser).create();
    //Gson gson = gsonBuilder.create();
    return (T) gson.fromJson(json, type);   
}

Exception code is :

    Jul 03, 2012 2:55:46 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/Login] threw  exception [Request processing failed; nested exception is java.lang.NumberFormatException: For  input string: "04-22-2011"] with root cause
 java.lang.NumberFormatException: For input string: "04-22-2011"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:441)
at java.lang.Long.parseLong(Long.java:483)
at com.google.gson.JsonPrimitive.getAsLong(JsonPrimitive.java:233)
at com.mpm.common.controller.DataUploadController$2.deserialize(DataUploadController.java:248)
at com.mpm.common.controller.DataUploadController$2.deserialize(DataUploadController.java:1)
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
at com.google.gson.Gson.fromJson(Gson.java:791)
at com.google.gson.Gson.fromJson(Gson.java:757)
at com.google.gson.Gson.fromJson(Gson.java:706)
at com.google.gson.Gson.fromJson(Gson.java:678)
at com.mpm.common.controller.DataUploadController.getJsonString(DataUploadController.java:253)
at com.mpm.common.controller.DataUploadController.saveGridData(DataUploadController.java:228)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

I am getting date parsing error please help me Thanks in advance.

  • 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-06-06T23:49:39+00:00Added an answer on June 6, 2026 at 11:49 pm

    The error is quite clear: NumberFormatException: For input string: "04-22-2011"] You are passing in a value that supposed to be a number but is actually in date format.

    I think it is where you do : json.getAsLong(), it expects to have a string like ‘12345654’ but instead it gets the date string.

    EDIT:

    Instead of doing:

    new Date(json.getAsLong())
    

    try:

    new Date(json.getAsString())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Been staring at this problem for a while now. Here's the error I'm getting
I have a problem running RoR project. I am getting this error while running
I was getting the below error when running scripts Problem while capturing system stateundefined
I'm getting crazy with a small problem here, I keep getting an error and
Please help me out here because im getting kind of confused.. I have a
Ok I've been searching for this problem for a while. I keep getting an
I am getting some problem while running ant Here is the details of problem:
I've got a weird problem here: I'm getting a 500 error code from Apache
Super weird problem here. I'm having trouble getting jQuery to bind any selectors except
After getting a helpful answer here , I have run into yet another problem:

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.