Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: unable to store, display date and time from db to extjs grid

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Location
    hyderabad
    Posts
    9
    My Mood
    Fine
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default unable to store, display date and time from db to extjs grid

    hi all,
    this is vanirathna,
    i have a table in db with the name b_announcements in that i took start_date,end_date fields with time stamp with time zone, i am trying to store values to that fields by a (extjs) form but they are storing in "2011-10-16 00:00:00+05:30" this format, time is not storing.when i am trying to display in the grid also same thing happening, i used

    /**
     * Displays announce in grid
     */
    package com.codon.action;
     
    import java.io.Reader;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Iterator;
     
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
     
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
     
    import com.codon.bean.B_Announcements;
    import com.codon.logic.Db_connect;
    import com.ibatis.common.resources.Resources;
    import com.ibatis.sqlmap.client.SqlMapClient;
    import com.ibatis.sqlmap.client.SqlMapClientBuilder;
     
    public class ShowAnnounce extends Action{
    	private final String SUCCESS="success.jsp";
    	public ActionForward execute(ActionMapping mapping,ActionForm form,
    			HttpServletRequest request,HttpServletResponse response)
    	throws Exception
    	{
    		try{
    		ServletOutputStream sos=response.getOutputStream();
    		response.setHeader("Cache-Control","no-store");
    		response.setHeader("Pragma","no-cache");
    		response.setContentType("text/xml");
    		SqlMapClient sqlMap=Db_connect.sqlMap;
    		ArrayList list=(ArrayList)sqlMap.queryForList("announcedetails",null);
    		Iterator itr=list.iterator();
    		sos.println("<dataset>");
     
    		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
     
     
    		while(itr.hasNext())
    		{
    			B_Announcements element=(B_Announcements)itr.next();
    			sos.println("<item>");
    		  	sos.println("<announce_id>"+element.getAnnounce_id()+"</announce_id>");	
    		  	sos.println("<name>"+element.getName()+"</name>");	
    		  	sos.println("<start_date>"+sdf.parse(element.getStart_date())+"</start_date>");	
    		  	sos.println("<end_date>"+sdf.parse(element.getEnd_date())+"</end_date>");	
    		  	sos.println("<information>"+element.getInformation()+"</information>");	
    		  	sos.println("<active>"+element.getActive()+"</active>");	
    		  	sos.println("</item>");
    		}//while
    		sos.println("</dataset>");
    		}catch(Exception e)
    		{
    			e.printStackTrace();
    		}
    		return null;
    	}//execute
    }

    please help me..
    thanks in adv..
    VaniRathna


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: unable to store, display date and time from db to extjs grid

    Hi,
    Please try format as dd-MM-yyyy'T'HH:mm:ss

    bean factory
    Last edited by abani; December 18th, 2011 at 02:09 AM.

  3. #3
    Member
    Join Date
    Nov 2011
    Posts
    37
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: unable to store, display date and time from db to extjs grid

    Hi,
    If you are json tag to create json object for grid then use there <fmt:formatDate along with the pattern you need.

    Core java
    Last edited by mr.miku; January 11th, 2012 at 07:14 PM.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: unable to store, display date and time from db to extjs grid

    Quote Originally Posted by mr.miku View Post
    Hi,
    If you are json tag to create json object for grid then use there <fmt:formatDate along with the pattern you need.
    Please stop resurrecting old threads. This question is now 9 months old.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Unable to view date
    By Rajiv in forum Web Frameworks
    Replies: 1
    Last Post: August 17th, 2011, 09:03 AM
  2. Need your help to display correct data by date
    By hanhtn in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 29th, 2011, 01:26 AM
  3. How to use SDF to display a future date.
    By amarettoCoffee in forum Object Oriented Programming
    Replies: 0
    Last Post: January 21st, 2011, 10:51 PM
  4. display time
    By kalees in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: January 1st, 2010, 07:40 AM
  5. How to Get the current date and time
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 2
    Last Post: December 2nd, 2008, 01:55 PM