Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , ,

Sponsored Links



Exactly match date in java

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 13-02-2010
Member
 
Join Date: Dec 2009
Posts: 192
Exactly match date in java

Hello,
I am trying a code in java and I want to do the following test if
Code:
(Date.getDay () = Sunday)
but because the method returns an int getDay I wanted to know the code on Sunday to an int? Do you have a solution for this , how to convert the integer to a string so that I can use it to compare it with the system date. In short I want to match the date with the system date. Thanks in advance.
Reply With Quote
  #2  
Old 13-02-2010
Member
 
Join Date: Nov 2009
Posts: 344
Re: Exactly match date in java

Hello,
Instead uses the Calendar object. Here is an example of use:
Code:
		GregorianCalendar td = new GregorianCalendar();
td.setTimeInMillis( System.currentTimeMillis() );

System.out.System.out.println("Day" + td.get( Calendar.Day_of_week ));
System.out.System.out.println("Month" + td.get( Calendar.MONTH ));

System.out.System.out.println("Day" + Calendar.TUESDAY );
System.out.System.out.println("Month" + Calendar.NOVEMBER );
Reply With Quote
  #3  
Old 13-02-2010
Member
 
Join Date: Nov 2009
Posts: 333
Re: Exactly match date in java

Hello,
For example, there 31 days in January after 30 then move to January 31 it is correct. Otherwise at this point, this is not the day of the week you are interested, but the day of the month ie DAY_OF_MONTH. I strongly advise you to take a look at the javadoc for the purpose Calendar. Just use the following code in your code and try if it works or else post back with the error you are getting.
Reply With Quote
  #4  
Old 13-02-2010
Member
 
Join Date: Dec 2009
Posts: 192
Re: Exactly match date in java

Hello,
I already looked CALENDAR class, but what I want some thing overall, I want to retrieve the last day of the month for any month, months ago or last day is 28 (February) months or is the other 30 or 31 is, I'm not going to do this for every month, there is certainly a method that gives the last day of a month. I was wondering if there is something like last_day_of_month. In addition I am forced to use the Date class and not Calendar.
Reply With Quote
  #5  
Old 13-02-2010
Member
 
Join Date: Nov 2009
Posts: 356
Re: Exactly match date in java

Hello,
Method getActualMaximum (Calendar.DAY_OF_MONTH) is for. Then it be enough just to do a set with the least number that interests. Incidentally Calendar goes hand in hand with the Date class. Do what you want only with the Date class is a heresy and incidentally to make ultra-heavy. In general it is better to intelligently work around a problem trying to solve it brutally.
Reply With Quote
  #6  
Old 13-02-2010
Member
 
Join Date: Nov 2009
Posts: 520
Re: Exactly match date in java

Hello,
As it is described above the, I have code for it, the code may help you. Here is the code for this. Check it out
Code:
Calendar c = Calendar.getInstance();
Date d = new Date();
c.setTime(d);
c.add(Calendar.DATE, 1);

Date d2 = c.getTime();
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Exactly match date in java"
Thread Thread Starter Forum Replies Last Post
Task Start Date does not match constraint ctslaton Microsoft Project 2 17-09-2011 05:57 AM
Getting Current Date in Java Level8 Software Development 5 27-02-2010 05:26 PM
Query with Date in java Gunner 1 Software Development 5 12-02-2010 03:55 AM
Manipulating a Date in java Linux-Us Software Development 4 07-02-2010 02:35 AM
How to match the most recent date with the project Elsie Software Development 5 04-05-2009 01:03 PM


All times are GMT +5.5. The time now is 07:47 AM.