Posted by: CrystalCracker May 19, 2007
Java Experts: Help Needed
Login in to Rate this Post:     0       ?        
I am trying to prevent the time user provides is not a time in the past. String userDate= request. getParameter("date);//yyyy-mm-dd String userTime= request.getParameter("time);//hh:mm (24 hour notation) DateFormat df= new SimpleDateFormat("yyyy-dd-mm hh:mm"); Date userDateTime=df.parse(userDate+ " " + userTime); Date serverTime= new Date(); if(serverTime.after(userDateTime){ return false; } This works well. But now I have to consider the user's time zone, and this is where I hesitate. The time zone user provides is in the format +7:30, -5 , 0 etc format from UTC. Is there any simple way to accomodate the time zone? or else I have to convert the user timezone input from +7:30 to 0700, which is the DateFormat requires in java for time zone. I dont want to do a lot of parsing. But is it the only way to do it? How are you guys been doing it?
Read Full Discussion Thread for this article