|
| |||||||||
| Tags: date, format, javautil, match, programming language |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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) |
|
#2
| |||
| |||
| 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 ); |
|
#3
| |||
| |||
| 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. |
|
#4
| |||
| |||
| 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. |
|
#5
| |||
| |||
| 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. |
|
#6
| |||
| |||
| 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(); |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |