Need help with dates  please-urgent

Hi folks, please help me with this if you can.
I run a weekly job, and need to have my java code create and use 2 dates to capture data for the whole week.
begin_date mm/dd/yyyy (String) to be 7 days prior to current date
end_date mm/dd/yyyy (String) to be the currecnt date
Note: please take into account the cases where the CURRENT_DATE is the first week of the month. As a result the 7 days prior will fall into the previous month. i.e if end_date="06/04/2003" then the begin_date will be "05/29/2003 Thanks a bunch

http://java.sun.com/j2se/1.4.1/docs/api/index.html
See the Calendar and DateFormat classes.

Similar Messages

  • Need Help with Dates

    I am printing a calendar and certain events will be helds on certain dates.
    One can edit the event if it has not passed the date. Events in the past can be viewed but not edited.
    When I query the database the date must be formatted dd-MMM-yy
    I am able to get today's date by doing this:
    java.util.Date today = new java.util.Date();
    String formatString = "dd-MMM-yy";
    SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    String today_str = sdf.format(today);
    My code for printing the calendar: I left out some of the table formatting in the JSP page.
    GregorianCalendar d = new GregorianCalendar();
    int today = d.get(Calendar.DAY_OF_MONTH);
    int month = d.get(Calendar.MONTH);
    d.set(Calendar.DAY_OF_MONTH,1);
    int weekday = d.get(Calendar.DAY_OF_WEEK);
    for(int i = Calendar.SUNDAY; i < weekday; i++)
    out.print("<td> </td>");
    do {
    int day = d.get(Calendar.DAY_OF_MONTH);
    out.print("<td>" + day + "</td>");
    String formatString = "dd-MMM-yy";
    SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    //if(event exists on this day
    // Get results
    // print link for viewing
    // if (after today) print link for edit
    if(weekday == Calendar.SATURDAY)
    out.println("</tr><tr valign=top>");
    d.add(Calendar.DAY_OF_MONTH,1);
    weekday = d.get(Calendar.DAY_OF_WEEK);
    } while(d.get(Calendar.MONTH) == month);
    if(weekday != Calendar.SUNDAY)
    System.out.println();
    The part I need help on is this:
    //if(event exists on this day
    // Get results
    // print link for viewing
    // if (after today) print link for edit
    I'm looping through each day of the month to print the days. I have the month, day, year as integers. How can I create a date object out of that and compare it to today's date to test if it's before or after today???
    All the function in the Date class that I think would do this have been deprecated.

    Need Help with Dates
    Here is some information about dates:
    There are many edible palm fruits, and one of the most widespread and favored of these is the data (Phoenix dactylifera). Dates were cultivated in ancient land from Mesopotamia to prehistoric Egypt, possibly as early as 6000 B.C. Then--as now--dates were a staple for the natives of those dry regions. Much later, Arabs spread dates around northern Africa, and dates were introduced into California by the Spaniards in 1765, around Mission San Ignacio.
    The date prefers dry, hot climates, because date fruits are injured at temperatures of 20 degrees F, and the damp climate of the California coast was not favorable for fruit production. In the mid-1800s, the date industry developed in California's hot interior valleys and in Arizona. Now the date industry in the United States is localized mostly in the Coachella Valley, where the sandy soils permit the plants to be deeply irrigated. Today the new varieties, mostly introduced in this century, produce about 40 million pounds of dates per annum, or over 60% of the dates consumed in this country. The rest are imported mainly from Persia. According to one survey, about one million people are engaged entirely in date palm cultivation worldwide.
    Hope that helps.

  • I have need help with something Please respond Quickly :)

    I have need help with something Please respond Quickly  ok so i have the linksys wrt54g Version 2.2 and i upgraded the firmware to V4.21.4 from this site http://homesupport.cisco.com/en-us/wireless/lbc/WRT54G and i clicked V2.2 for the router. So after i upgraded i lost internet ability i can't use the internet so i had to downgrade back to V4.21.1 but i want the things that newer update sloves. Please Help. Everything thing says DNS error? aka Modem.
    $$Cgibbons$$

    Ya i tried that i tried restoring and redoing everything when i downgrade back to .1 it works fine though?
    $$Cgibbons$$

  • Need help in date Validation Urgent

    Hi ,
    We need help in Date Validation.
    we have 2 Date fields on the form Start Date, End Date
    The requirement is: End Date (May not be greater than 30 years from the start date).
    I have written following script on End Date Exit event. But the problem is its calculating 30 years from the Current Date not from the Start Date
    var tDate = util.scand("mm/dd/yyyy", new Date());
    var M = tDate.getMonth();
    var D = tDate.getDate();
    var Y = tDate.getFullYear();
    var SRes = util.printd("yyyy-mm-dd", new Date((Y+30), M,D) );
    //app.alert(SRes)if (SRes <= this.rawValue){
    app.alert("May not be greater than 30 years from the start date")
    xfa.host.setFocus(
    this);}
    can someone please help me
    Regards,
    Jay

    Hi,
    You'll need to get javascript date from LCD field, and calculate & compare with the future date in javascript date.
    try following script;
    var sDate = StartDate.rawValue;
    var wkStartDate = util.scand("yyyy-mm-dd", sDate);
    var nYear = wkStartDate.getFullYear();
    var nMonth = wkStartDate.getMonth();
    var nDay = wkStartDate.getDate();
    var wkFutureDate = new Date(nYear  + 30 , nMonth, nDay);
    sDate = EndDate.rawValue;
    var wkEndDate = util.scand("yyyy-mm-dd", sDate);
    if (wkEndDate.getTime() > wkFutureDate.getTime()){
      xfa.host.messageBox("May not be greater than 30 years from the start date");
      xfa.host.setFocus(this);

  • Need Help with data type conversion

    Hello People,
    I am new to java, i need some help with data type conversion:
    I have variable(string) storing IP Address
    IPAddr="10.10.103.10"
    I have to call a library function which passes IP Address and does something and returns me a value.
    The problem I have is that external function call in this library excepts IP Address in form of a byte array.
    Here is the syntax for the function I am calling through my program
    int createDevice (byte[] ipAddress).
    now my problem is I don't know how to convert the string  IPAddr variable into a byte[] ipAddress to pass it through method.

    Class InetAddress has a method
    byte[]      getAddress() You can create an instance using the static method getByName() providing the IP address string as argument.

  • Need help with XML delay   URGENT!!!

    Hi i need help making a flash movie to load everything from
    xml. It has to load text, images and flv, but, it has to load them
    and end them at the time said in the xml. So flash loads and
    unloade the text or image or video at the time specified in the
    XML! PLEASE HELP I NEED THIS DONE TODAY!!!!! VERY IMPORTANT!!!
    Contact me by msn [email protected] or send mail or
    reply here!!

    It was probably a little unclear initially (no offence
    intended ) whether your problem was with getting the data from XML
    or with the sequencing aspect. I assume that its the sequencing
    aspect based on your recent reply.
    So if it was me I would parse the loaded info into Date
    objects for the load and remove times and have this information
    handled by some sort of sequencing code.
    At its simplest, you could compare the xml-derived date/times
    for load/unload with the current system date/time and use a
    setInterval function to initiate the load after the calculated
    difference in milliseconds has passed. Similar for the removeclip
    timing.

  • Need help with date range searches for Table Sources in SES

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 10-MAR-07, 22-SEP-07, 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks very much, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • Need help with Fancybox please

    Hola
    I need some help with Fancybox.
    I bought this template and it came without facybox, so I thought
    that this will be a great help to learn some about jQuerry, but I'm lost
    Why is NOT working on my page?
    I just cannot figure this out.
    Can you please check my page?
    http://tummytime.biz/pages/portfolio_fancy.html
    I got Windows 8, Dreamweaver CC
    Thanks a lot.

    There are a couple things that could be causing a couple browsers' collective heads to implode.
    Remove the <! right before your </head> tag...
    </script>
    <!
    </head>
    <body>
    You have two calls to the fancybox css file, you only need one.
    Aside from that I'm not seeing any code problems jump out at me.
    EDIT: Ah, didn't scroll far enough. You have more than one reference to the jquery library. Typically, only one is needed and two or more will cause them all to fail. Usually, you can use the "latest" link and cover all your bases.
    If you aren't using those referenced scripts at the bottom of your page, delete them.

  • Need Help With Home Please

    If anyone here is good with Java, I need serious help with my homework, please give me your instant messenger screen name and we can chat, thanks alot!!
    Angela

    I don't understand how people get themselves into
    these situations as school, if you don't want to learn
    it don't sign up for the class.....You never got yourself into this situation.... I think everyone has on occassion.
    My very first "serious" university program was to solve a second order, non-linear differential equation using the Runge-Kutta method. This is NOT the easy way to learn a computer language and I have to admit I did take "shortcuts" using more experienced people than me.
    That was before the web though...
    God am I really that old?

  • HT3702 need help with purchase please!!!

    My husband mistakenly hit the purchase button las night for an apple app and now it has been taken out of our account, but was deleted off the phone as soon has he realized that he hit the purchase button how do we get a refund please we need HELP!!!

    All sales are final
    You can try contacting itunes and asking for an exception

  • I need help with this please

    javax.servlet.ServletException
    at com.evermind.server.http.EvermindPageContext.handlePageThrowable(EvermindPageContext.java:595)
    at com.evermind.server.http.EvermindPageContext.handlePageException(EvermindPageContext.java:537)
    at jsp.addservice._jspService(addservice.jsp:515)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:356)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:498)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:402)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:847)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:340)
    at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:229)
    at mil.usmc.m4l.servlets.M4LServlet.forward(M4LServlet.java:34)
    at mil.usmc.m4l.servlets.EditService.doGet(EditService.java:120)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    at mil.usmc.m4l.filters.M4LCMSFilter.doFilter(M4LCMSFilter.java:150)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:673)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:340)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:534)
    Edited by: user11237193 on Apr 27, 2010 10:58 AM
    I am getting error and I ned help with it Thank you for your help.

    I'd enter the dell service tags in here to find out what OS the pc was designed for.
    http://www.dell.com/support/contents/us/en/19/Category/Product-Support/Self-support-Knowledgebase/locate-service-tag?~ck=mn
     For windows I'd ask over here.
    http://answers.microsoft.com/en-us/windows
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Need help with debugging PLEASE

    Hi,
    I'm new to Java and was given an assignment to debug a program. I am completely lost and really havent gone over most of the stuff that is in this program. I would greatly appreciate any help with this that I can get.
    Here is my code:
    import java.util.*;
    import javax.swing.*;
    public class IndexHitFrequency
    private final int NUMBER_OF_SIMULATIONS = 1000;
    private int indexHit[] = new int [10];
    public IndexHitFrequency()
    Random generator = new Random(); // for generating random number
    int array[] = {6, 2, 4, 8, 5, 0, 1, 7, 3, 9 };
    //convert to ArrayList and sort it
    List list = new ArrayList(Arrays.asList(array));
    for (int i = 0; i < NUMBER_OF_SIMULATIONS; i++)
    //generate random number
    int randomNumber = generator.nextInt(array.length);
    // get index hit
    int index = Collections.binarySearch(list, randomNumber) ;
    // save index hit to array
    if(index > -1)
    indexHit[index]++;
    }//end for
    String output = "Index\tFrequency\t\n";
    //append the frequency of index hit to output
    for (int i = 0; i < indexHit.length; i++)
    output += i + "\t" + indexHit[i] + "\t\n";
    //display result
    JTextArea outputArea = new JTextArea();
    outputArea.setText(output);
    JOptionPane.showMessageDialog(null, outputArea, "Search random number 1000 times" ,
    JOptionPane.INFORMATION_MESSAGE);
    System.exit(0);
    }// end constructor
    public static void main (String [] args)
    new IndexHitFrequency();
    } // end class IndexHitFrequency
    I get these errors after trying to compile:
    "IndexHitFrequency.java": Error #: 300 : method asList(int[]) not found in class java.util.Arrays at line 17, column 40
    "IndexHitFrequency.java": Error #: 300 : method binarySearch(java.util.List, int) not found in class java.util.Collections at line 24, column 34

    C:\Java\Tutorial\rem>javac IndexHitFrequency.java
    IndexHitFrequency.java:15: asList(java.lang.Object[]) in java.util.Arrays cannot
    be applied to (int[])
    List list = new ArrayList(Arrays.asList(array));
                                    ^
    IndexHitFrequency.java:22: cannot find symbol
    symbol  : method binarySearch(java.util.List,int)
    location: class java.util.Collections
    int index = Collections.binarySearch(list, randomNumber) ;
                           ^
    2 errors
    C:\Java\Tutorial\rem>Copied source and compiled in DOS window ( XP's cmd.exe) and got these error messages...
    I think these error are more clear than the ones you posted, so this should help you resolve the problem...
    - MaxxDmg...
    - ' He who never sleeps... '

  • Need help with date and time calculations please

    Hello there.. Im stuck, and im hoping someone can help..
    Working on a list to manage and track PTO.  User completes PTO request form,
    Fields
    Name
    Start Date (with time)
    End Date (with time)
    Total Number of Days/hours requested: (calculation)
    Full Day: (Yes/No)
    ok business need
    user has the ability to request a certain number of hours as opposed to a full day.
    After searching around on google. I found this calculation to help me figure out how many BUSINESS days being requested.
    =IF(ISERROR(DATEDIF([Start Date],[End Date],"d")),"",(DATEDIF([Start Date],[End Date],"d"))+1-INT(DATEDIF([Start Date],[End Date],"d")/7)*2-IF((WEEKDAY([End Date])-WEEKDAY([Start Date]))<0,2,0)-IF(OR(AND(WEEKDAY([End
    Date])=7,WEEKDAY([Start Date])=7),AND(WEEKDAY([End Date])=1,WEEKDAY([Start Date])=1)),1,0)-IF(AND(WEEKDAY([Start Date])=1,(WEEKDAY([End Date])-WEEKDAY([Start Date]))>0),1,0)-IF(AND(NOT(WEEKDAY([Start Date])=7),WEEKDAY([End Date])=7),1,0))
    This works great as long as its a [Full Day]="YES", displays results in column labeled Number of days
    now if [Full Day]="No", displays results in column labeled Number of Hours
    BUT this is my issue (well part of it) it calcuate the correct number of hours.. but puts a "1" in "Number of Days" why.. dates have not changed.. I think Its something with the above calculation but I could be way off.
    the end result is I need number of days to concat with number of hours 
    i.e 1 full day 4 hours  1.4
        0 full day 5 hours  0.5
        1 full day 0 hours  1.0
    so that the total can be deducted via workflow.. from the remaining balance in a tracker. (seperate list) 
    Any angels out there??

    Posnera-
    Try changing time zones and see if the travel itinerary times change.
    Fred

  • Need help with itunes proxy, URGENT!!! please reply

    Hello, im currently living in boarding school, and the wifi, recures a proxy server, I got it, and now i can acces internet perfectly, I can do everything perfectly, but when i go into the itunes store and try to buy something, this is what comes up. "We can not complete yout Itunes store request, you must log in into the proxy server in order to confirm your request."
    so how do I sign into the proxy server,
    PLEASE HELP

    Hey,
    Try downloading and re-installing iTunes as described here:
    http://support.apple.com/kb/TS2388
    Jason

  • I need help with hyperlink PLEASE!!!!!!!

    I hope somebody can help me with this question. I create some
    button in flash 8. My web page is divided in three frames( using
    the frame tag), two rows and the second row has two colums. My
    question is how can i make one of my buttons to open a new web page
    but in a different frame. The button is in column number 1 of row 2
    and when the user click this button i want that this new page open
    in column number 2 of row 2. How can ia do that? please help
    me

    valla23 wrote:
    > I hope somebody can help me with this question. I create
    some button in flash
    > 8. My web page is divided in three frames( using the
    frame tag), two rows and
    > the second row has two colums. My question is how can i
    make one of my buttons
    > to open a new web page but in a different frame. The
    button is in column number
    > 1 of row 2 and when the user click this button i want
    that this new page open
    > in column number 2 of row 2. How can ia do that? please
    help me
    Always best to google before posting, especially if you
    urgent to meet deadline.
    Forum archives:
    http://groups.google.com/advanced_group_search?q=group:macromedia.flash.*&hl=en&lr=&ie=UTF -8
    Search "flash in frames"
    the very second result, so happen to be from me, exhaling
    exactly how to set it up.
    http://groups.google.com/group/macromedia.flash/browse_thread/thread/6b0047b0a65be8a0/9f8f c0765bf2297e?lnk=st&q=&rnum=2&hl=en#9f8fc0765bf2297e
    Personally posted that couple of hundreds of times in past 8
    years.
    Please try to utilize the search before posting so we don't
    need to hammer same
    topic over and over and over and over and over .....again...
    Best Regards
    Urami
    !!!!!!! Merry Christmas !!!!!!!
    Happy New Year
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

Maybe you are looking for

  • Huge Problem with iCloud...

    Hopefully someone can help me out here. I have an iPhone and an iPad.  Ever since setting up iCloud I've had a ton of problems and I don't know if what I want is possible. How can I set a criteria for when my contacts sync? My phone synced to my comp

  • ITunes shared library on Buffalo Linkstation NAS

    Hi all I've recently put in a Buffalo NAS, which has an onboard media server. iTunes can see it fine and to begin with, it worked superbly. After making a couple of network changes this weekend (put a fixed IP on one of the computers and moved all my

  • Desperate...Premiere not recognizing any video

    Hi everyone!  I'm obviously very desperate if I'm posting to a forum for help.  The problem is my clips won't show in the timeline. When I drag and drop the video file, every single thing I've read online states that it should AUTOMATICALLY separate

  • Changed sort now it wont open

    I changed my sort by and now Aperture will not open. Just spinning icon and "Opening Aperture Library"

  • Sort my bookmarks in drop down lists in alphabetical order not just in Library Views

    When I click on Bookmarks then select a folder to view its contents, I want to see those contents in alphabetical order By Name, not in the hpahazard order in which they were added. I know I can View them in the Library List in alphabetical order or