Check out this link

http://www.java2s.com/Code/Java/JPA/DateTypeParameter.htm

Regards
Captain


On May 4, 9:14 pm, Ramesh <ramesh.v1...@gmail.com> wrote:
> Hi all,
> Even after searching i am not able to see any correct answer on how to
> work with GAE java dates.
>
> My Model:
> /**
>  */
> @Entity
> @Table(name = "testDetail")
> public class TestDetail {
>
>         /**
>          *
>          */
>         private static final long serialVersionUID = 1L;
>
>         /**
>      */
>     @Column(name = "spreadSheetName", length = 2000, nullable = false)
>     private String spreadSheetName;
>
>    /**
>      * The date the entity was created.
>      */
>     @Column(name = "created_on", nullable = false)
>     @Temporal(TemporalType.TIMESTAMP)
>     private Date createdOn;
>
>     /**
>      * The date the entity was last modified.
>      */
>     @Column(name = "modified_on", nullable = false)
>     @Temporal(TemporalType.TIMESTAMP)
>     private Date modifiedOn;
>
>     /**
>      */
>     @Column(name = "id", nullable = false)
>     @GeneratedValue(strategy=GenerationType.SEQUENCE)
>     @Id
>     private Long id;
>
>     //all setters and getters
>
> }
>
> And the dates in GAE datastore is stored in this format "Sat Apr 23
> 18:25:28 UTC 2011"
>
> I am using JPA and my dao looks like this
>
> public class TestDetailDaoImpl extends JpaDaoSupport {
>
>         @Autowired
>         public TestDetailDaoImpl(EntityManagerFactory entityManagerFactory){
>                 setEntityManagerFactory(entityManagerFactory);
>         }
>
>         public List<TestDetailDetail> findAllByDate(Date fromDate, Date
> toDate) {
>                 List<TestDetail> testDetailList=null;//List<Object[]>
>                 try{
>                         String query="Select  from 
> "+TestDetail.class.getName()+" where
> createdOn>="+fromDate.getTime()+" and createdOn <"+toDate.getTime()
> +"";
>                         log.info(query);
>                         testDetailList=getJpaTemplate().find(query);
>                         log.info("testDetailList:"+testDetailList);
>                 }
>                 catch(RuntimeException re){
>                         re.printStackTrace();
>                         throw re;
>                 }
>                 return testDetailList;
>         }
>
> }
>
> The above findAllByDate method always returns zero rows, even it has
> data valid in it.
>
> Can any one please tell me how should i handle dates in java.
> Thanks....

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to