473,471 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

calender validation

50 New Member
I am having a problem in finding out whether a date inserted by the user happens to be before the current todays date.

The problem is this.. The date that the user inputs is in the format of simpledateformat dd-MM-yyyy. Therefore i cannot use the date.before() since simple date format is of type calender. Also the date that the user is going to insert is going to be placed in a text field. Therefore i need to get it from there and compare it to the current's date. I tried to use the calender.getInstance(), though i did not suceed.

If someone can help me, it would be really appreciated. Thanks
Jan 3 '08 #1
2 1109
BigDaddyLH
1,216 Recognized Expert Top Contributor
Demo:

Expand|Select|Wrap|Line Numbers
  1. import java.text.*;
  2. import java.util.*;
  3.  
  4. public class CalendarExample {
  5.     public static void main(String[] args) throws ParseException {
  6.         Calendar c = Calendar.getInstance();
  7.         Date now = c.getTime();
  8.         DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
  9.         Date then = df.parse("2008-01-02");
  10.         System.out.println(then.before(now));
  11.     }
  12. }
To be more careful, I should have moved the current time back to midnight.
Jan 3 '08 #2
BigDaddyLH
1,216 Recognized Expert Top Contributor
If I had been picky, I would have posted this ;-)

The problem is this.. The date that the user inputs is in the format of simpledateformat dd-MM-yyyy. Therefore i cannot use the date.before() since simple date format is of type calender.
Huh? java.text.SimpleDateFormat parses strings into Date objects, so you can use before.

I tried to use the calender.getInstance(), though i did not succeed.
Insufficient data for a meaningful response.
Jan 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: jason | last post by:
Hi Everyone, I would really appreciate some thoughts on how best to tackle an availability calender in ASP for our yacht fleet. I need to be able to show the booking STATUS of a particular...
8
by: PerryC | last post by:
I want to be able to accomplish this, please help: When click on the DOB field, a ActiveX Calender popup and the user choose a date, the value is automatically refreshed in the DOB field in the...
4
by: Chris | last post by:
Hi, I am trying to create a popup calender so a user can click on a button on the main form, a calender will then popup, the user will select a date and then click ok on the popup. The date will...
3
by: Learner | last post by:
Hi there, I have a text box in my webform to type in a date. I want to take advantage and use the calender control to let the user just to click on the clander and select a date. How do i...
0
by: Steven Blair | last post by:
Hi, I would like to create a Calender effect like this website: http://www.expedia.co.uk/default.aspx This site uses ASP.NET, so I guess we should be able to use VS 2005 to recreate this. ...
0
by: kalichakradhar | last post by:
hi all, hi, I am developing a application which would open the shared calender of outlook and read the meeting notices and also modifies the meeting notice from Vb.I am successful in opening the...
7
by: gubbachchi | last post by:
Hi all, In my application I need to display the data fetched from mysql database after the user selects date from javascript calender. I have written the code in which after the user selects the...
21
Vkas
by: Vkas | last post by:
i had created my own web calender control!!!! it consist 1} text box (it display's the selected date) 2} button (it hide and show the calender control) 3} calender control (use for the selection...
1
by: xtremebass | last post by:
Hello Bytes, i have a calender program which is created by using Javascript. when i execute that program using Internet Explorer,it works properly but when i tried in Mozilla firefox it didnt...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.