473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Calendar Class rollback

17
when we use the calendar class and enter the date in date object as 45/8/2007(dd/mm/yyyy). it will automatically roll forward as 15/9/2007(dd/mm/yyyy)

Logically this should not happen as date cannot be greater than 31 ,

How to avoid roll back and i also need help in validating date

thanks in advance
Jan 10 '08 #1
2 1354
dmjpro
2,476 2GB
when we use the calendar class and enter the date in date object as 45/8/2007(dd/mm/yyyy). it will automatically roll forward as 15/9/2007(dd/mm/yyyy)

Logically this should not happen as date cannot be greater than 31 ,

How to avoid roll back and i also need help in validating date

thanks in advance

Then I think it can not be done using Calendar Class.
Then you should have your own Class.
Wait sometimes let the experts say.
Then proceed with your own class.

Debasis Jana
Jan 10 '08 #2
BigDaddyLH
1,216 Expert 1GB
Have you looked at the API? You would have found the method setLenient in both DateFormat and Calendar:

DateFormat.setLenient
Calendar.setLenient

Your note made it sound like you are not using DateFormat, but you should use it to parse dates. Here is a demo showing the effect of setLenient:

Expand|Select|Wrap|Line Numbers
  1. import java.text.*;
  2. import java.util.*;
  3.  
  4. public class DateParsingExample {
  5.     public static void main(String[] args) {
  6.         String data = "45/8/2007";
  7.         DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
  8.         boolean[] lenientSettings = {true, false};
  9.  
  10.         for (boolean lenient : lenientSettings) {
  11.             try {
  12.                 df.setLenient(lenient);
  13.                 System.out.println("lenient = " + lenient);
  14.                 Date date = df.parse(data);
  15.                 System.out.println(date);
  16.             } catch (ParseException e) {
  17.                 e.printStackTrace();
  18.             }
  19.         }
  20.     }
  21. }
Jan 10 '08 #3

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

Similar topics

19
by: Stimp | last post by:
preferably one that when clicked can update three date dropdowns (day, month, year) like http://www.visitdublin.com/carhire/avis.asp Don't mind paying for the file... anyone seen something...
12
cassbiz
by: cassbiz | last post by:
I downloaded this calendar off the web and am trying have it show twice, once as calendar.php and the second time as calendar1.php I need the visitor to be able to select a beginning date and an...
2
by: Kajsa Anka | last post by:
Before I re-invent something I would like to ask if there exists some code that can be used for create the HTML code for a calendar which I then can include on a web page. The module in the...
3
by: antred | last post by:
Hello everyone, While working on a program I encountered a situation where I'd construct a largish data structure (a tree) from parsing a host of files and would end up having to throw away...
2
by: ashishjainism | last post by:
I am unable to install my windows service and the installutil is throwing the following error: Running a transacted installation. Beginning the Install phase of the installation. See the...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
1
by: abhishekbrave | last post by:
The code below is opening a calendar on mouse over in the same window. I need the calendar to be opened in new window. Have to fulfill this requirement urgentely so posting the whole code here. I...
1
by: swethak | last post by:
hi, i have a code to disply the calendar and add events to that. It works fine.But my requirement is to i have to disply a weekly and daily calendar.Any body plz suggest that what modifications i...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.