How to calc the begining and end of every month (leap year)

Hi all,
I'm looking for a method that returns the begining and end of next month.
example:
today is 2005-10-04
so the method suppose to return:
2005-11-01
2005-11-31 //as it ends on the 31
I came up with the code below - but I don't like it as I can't get the end of month + it's not safe.
any suggestions.
Thanks
Peter
Calendar gcToday = Calendar.getInstance();
          int month = gcToday.get(Calendar.MONTH);
          int year  = gcToday.get(Calendar.YEAR);
          month+=2;
          if(month>12) //beacuase of month+=2;
               year++;
               month=1;
          String nextMonth;
          if (month<10)                         
               nextMonth=year+"-0"+month+"-01";
          else
               nextMonth=year+"-"+month+"-01"; 

Look at using the methods getActualMaximum() and getActualMinimum() in the Calendar class. Basically what I would do is set the calendar to the 15th of the month (well, really anything between 1 and 28) and then add() one to the current month. The Calendar will roll over the dates as needed.

Similar Messages

  • How can I put asterisk in the beginning and end of a search parameter..?

    Hi!
         I'm developing a program for a user where he wants a search parameter for the description about some purchase orders....
    The problem is if the user want to make a search for any word he need to put asterisk in the beginning and end of the word because if the user don't put the asterisk the search will not find anything because the program don't know if the word is in the beginning of the description or in the end or in the middle...
    How can I put one asterisk in the beginning and end of the search topic entered by the user internally in the program..? I was thinking using the concatenate function but for this will not work because the program think that the asterisk is part of the word and not..
    The search parameter of the Description is in range.. (Select-Options).
    Thanks for your help!!

    Thanks keshav!
    OK... and if I concatenate the asterisk latter I can make this search?
    In the code desc_search is the select_option that I tell u. I use the DESCRIBE to see first if it is not initial... if desc_search have an entry then access the DELETE to remove all the records that are diferent from desc_search.. This desc_search will have the word with the asterisk... and the question is if it works if I use the concatenate before this... anyway I will try but I think that if I use the concatenate the program confuse and take the asterisk as part of the word..
    DESCRIBE TABLE desc_search LINES desc_count.
      IF desc_count IS NOT INITIAL.
        DELETE core_table WHERE desc NOT IN desc_search.
      ENDIF.
    Let u know if works!!
    Thanks!

  • How do I remove residual frames at the beginning and end of a video?

    I'm making a short clip with black slugs at the beginning and end. But there are two or three residual frames from the incoming clip after the black clip that stay at the beginning and end of the video and I can't remove them.  I've tried trimming the beginning and end of the video several different ways, and the frames won't disappear. They stay in the video when I make a DVD. The very first and very last frame have sprocket holes in them on the edge of the frame. I'm baffled. Is this an artifact of using the trial version?

    chances are they are from a fade.  have you zoomed in really really close and checked if there is a small fade in or fade out?  happens to me all the time, and with the fade out, you can't do anything to fix it (that I've found) except replacing the clip from your Browser.  See my similar question here:
    https://discussions.apple.com/thread/3589714
    Hope that helps.

  • Removing punctuation from the beginning and end of a string

    I am working on a project for a "spell checking" program. So far the StringHash class is made, and the dictionary is read into a hash table. Then the document to be checked is specified via command line, the document scans through each word and checks to see if it is in the dictionary, if it is do nothing, if it is not then display it to console. The problem I am having is with a method in the main class. The method (I will post what I have so far) is called removePunct. The method should remove any punctuation from the beginning and the end of the string, nothing from the middle. Here is what I have so far:
    public static String removePunct(String word){
              StringBuilder wo = new StringBuilder(word);
              int x = (word.length()-1);
              if(!Character.isLetter(wo.charAt(0)))
                   wo.deleteCharAt(0);
              if(!Character.isLetter(wo.charAt(x)))
                   wo.deleteCharAt(x);
              return wo.toString();
    Any help would be much appreciated, I'm pretty certain the solution is either something completely different, or something so simple that I just missed it.

    The easiest way to do this is to just show you the actual file to be spell checked:
    -- outline --
    This directory contains Bison skeletons: the general shapes of the
    different parser kinds, that are specialized for specific grammars by
    the bison program.
    Currently, there are only three supported skeletons:
    - yacc.c
    It used to be named bison.simple: it corresponds to C Yacc
    compatible LALR(1) parsers.
    - lalr1.cc
    Produces a C++ parser class. It is still very experimental, and not
    yet supported. Please, subscribe to [email protected].
    - glr.c
    A Generalized LR C parser based on Bison's LALR(1) tables.
    These skeletons are the only ones supported by the Bison team.
    Because the interface between skeletons and the bison program is not
    finished, we are not bound to it. In particular, Bison is not
    mature enough for us to consider that ``foreign skeletons'' are
    supported.
    Copyright (C) 2002 Free Software Foundation, Inc.
    This file is part of GNU Bison.
    GNU Bison is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, or (at your option)
    any later version.
    GNU Bison is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with Bison; see the file COPYING. If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
    What I need the spell checker to do is read each word, and strip any beginning or ending punctuation, e.g. (c) would become c. Pretty much punctuation consists of anything that is not a letter, hence the use of isLetter. I can easily modify the method to remove all punctuation using regular expressions, but I only want the beginning and end characters removed.
    Example of words:
    -yacc.c would become yacc.c and is not in the dictionary so it would be printed.

  • Can you adjust audio volume at the beginning and end of a clip?

    I want to add portions of songs into my iMovie videos. When I do that they abruptly start and end. Is there no way to adjust add a fade at the beginning and end of an audio clip?

    As said above, you cannot.
    The only work around is to edit audio in an external app.
    So please do suggest to Apple to add this feature in the next update.
    http://www.apple.com/feedback/imovie_iOS.html

  • How to find the start and ending dates of a quarter of a particular fiscal

    Hi Experts,
    I need a function mudule which returns starting and ending date s of a particular quarter of a particular fiscal year .
    For Example: if pass 1 quarter and 2002 or 2 quarter 2002 it has to give me the star and end dates of that particular quarter na d fiscal year.
    Please help me which is urgent for me.

    Hi Kishan thanks for reply.
    But given function module the 2nd one is full but it is giving me the calender year dates but i need fiscal yea dates.
    fro example: if i pass 1 st quarte and 2006 it is to give me the 1st-april to 30-jun2006.
    And need this quater starting date and ending date for as per USA fiscal year calender.
    If u get any idea plz let me know.
    thanks.
    Dashmantha.

  • How to find the start and end duration of "Selected frames" from Video using didFinishPickingMediaWithInfo?

    I am doing slow motion in audio and video using AVFoundation(for Video) and Dirac(Audio). As part of it, i will show the video as frames in which the user will select the frames to do slow motion. Eg: 5-6 min of 10 min video.
    I have to show the users two kinds of videos 1. through the video recorder from my application itself. 2. from the gallery.
    Case1: No problem Now,i can record the videos though my video recorder and show the videos as frames to the user to select. Once the user selects some frames(Eg: 5 to 6 min of 10 min recorded video), using the below code, i am able to find the start/end duration of the selected frames or video.
    NSNumber *start = [info objectForKey:@"_UIImagePickerControllerVideoEditingStart"]; NSNumber *end = [info objectForKey:@"_UIImagePickerControllerVideoEditingEnd"];  int startMilliseconds = ([start doubleValue] * 1000);int endMilliseconds = ([end doubleValue] * 1000);
    Case2: In this case, i am able to pick the video from the gallery and show them to the user in the form of frames to select. However, when i try to find the start/end duration of the video as i did in case 1 with the same code, its not working. I am always getting "0" for start/end duration.
    Can you please give some suggestion on my Issue ?

    +1 .. also. i'd to know is using "_UIImagePickerControllerVideoEditingStart"
    the app won't be rejected..
    thanks,
    F

  • HT4009 How to stop the purchases being taken out every month?

    I had two app that i was using, and i done a purchases for it to be taken out every month but I want to stop it but i dont know how to stop it.

    There are instructions on this page for managing and stopping auto-renewing subscriptions : http://support.apple.com/kb/HT4098

  • How do I clean up the begining and ends of tracks?

    I can't seem to clean up tracks before committing them to disc.

    I can't seem to understand this question because it is so extremely vague.

  • How to find the start and end sector index/physical address of any given file?

    I need to find the range of sectors that a file occupied. Then determine the slack space in that file and then analyze the slack space. This is a forensics project work. I am new to forensics and have no idea what Window API calls may help me accomplish
    this task. Any kind of help will be appreciated. 

    One solution if you want all the dates in one column:
    SQL > SELECT *
      2  FROM
      3  (
      4     SELECT  (CASE WHEN ID = 1 THEN TRUNC(MTH,'MONTH') ELSE ADD_MONTHS(TRUNC(MTH,'MONTH'),1)-1 END) AS MTH
      5     FROM
      6     (
      7             SELECT  ADD_MONTHS(TO_DATE(:begin_month,'MM/DD/YYYY'),LEVEL-1) AS MTH
      8             FROM    DUAL
      9             CONNECT BY LEVEL <= ABS(MONTHS_BETWEEN(TO_DATE(:begin_month,'MM/DD/YYYY'),TO_DATE(:end_month,'MM/DD/YYYY')))+1
    10     )
    11     CROSS JOIN
    12     (
    13             SELECT 1 AS ID FROM DUAL UNION ALL
    14             SELECT 2 FROM DUAL
    15     )
    16  )
    17  WHERE MTH BETWEEN TO_DATE(:begin_month,'MM/DD/YYYY') AND TO_DATE(:end_month,'MM/DD/YYYY')
    18  ORDER BY MTH
    19  /
    MTH
    03/31/2009 00:00:00
    04/01/2009 00:00:00
    04/30/2009 00:00:00
    05/01/2009 00:00:00
    05/31/2009 00:00:00
    06/01/2009 00:00:00
    06/30/2009 00:00:00
    07/01/2009 00:00:00
    07/31/2009 00:00:00
    08/01/2009 00:00:00
    08/31/2009 00:00:00
    09/01/2009 00:00:00
    09/30/2009 00:00:00
    10/01/2009 00:00:00
    10/31/2009 00:00:00
    11/01/2009 00:00:00
    11/30/2009 00:00:00
    12/01/2009 00:00:00
    12/31/2009 00:00:00
    01/01/2010 00:00:00
    01/31/2010 00:00:00
    02/01/2010 00:00:00
    02/28/2010 00:00:00
    03/01/2010 00:00:00

  • Find beginning and end of an XMLtag in text

    I am trying to find the beginning and end of an xml tag in a block of text using a script. Does anybody have any ideas on how to locate the beginning and end of an xml tag in text?
    You can see the ends of a tag visually from the user interface by the colored brackets that appear. So one of my ideas is to use a function to find the brackets. Does anyone know if those brackets have a character number, or some way to identify them?

    -257 is 0xFEFF (as a signed 2 byte word).
    I don't think that's a terribly reliable way of checking XML tags (I seem to remember this is more an internal "IsNotUsual" code for ID). And you don't know if it's a start or end tag.
    Your script may or may not pick up this code in the selected string, depending on where you start and end your selection. You can use regular string functions to remove them from the string.
    Perhaps it's better to walk over the XML tree and check if each element's start and end value ("storyOffset" for the start, a quick eyeballing of the help didn't reveal a good candidate for its end) is at the start and end of your selection.

  • How to calculate first date and end date of this year in Query

    Hi Expert
    I want to calculate following dates with inputted date in query.
    I have no knowledge on ABAP and I just can create a query with simple logic.
    Could you teach me how to calculate following date?
    (If inputted date is April 12 2009)
    - First date of this year (Ex January 1 2009)
    - End date  of this year (Ex December 31 2009)
    - First date of last year (Ex January 1 2008)
    - End date of last year  (Ex December 31 2008)
    - First date of this month (Ex April 1 2009)
    Thank you!
    Take

    HR_JP_MONTH_BEGIN_END_DATE   use this FM to get the begin and end date of the Date you are passing. eg when u give input as 04/12/2009, it will return
    04/01/2009 as begin date
    04/30/2009 as end date
    pass the Year in this FM HR_E_GET_FISC_YEAR_DATES, you will get the Fiscal year Begin and End Dates
    Abh

  • Auto trim out silence at beginning and end?

    Audition 3
    Anyone know if there is an option to automatically trim out the silence at the beginning and end of audio file?  If so, how?

    Sorry, no there isn't* - and if there was, most people wouldn't use it because a really hard start or end is rarely what's required. Anyway, it wouldn't really be any quicker than just highlighting the amount of silence you want to remove, and hitting the 'delete' key - and that method has the advantage of letting you select exactly where to trim.
    *Unless it's digital silence, in which case there's an option under edit>automark - but this won't work with anything other than digital silence at the start and/or end.

  • Inventory Management 0IC_C03: Beginning and ending inventory

    Hi Gurus
    My report is based on Inventory Management cube and I have a requirement where in I need to show Begining Inventory and Ending Inventory for Plant per Period.
    There is no KF for Beginning Invin SAP standard model in inventory management cube (0IC_C03 cube), so I thought to restricting total quantity by Fiscal period and Offset by minus one to get begining inventory.
    Here is my report layout:
    I have got : Period , Plant in rows and Beginning and ending inventory in Columns.
    Desired Output:
    Fiscal Period | Plant |  |  Begining Inventory | Ending Inventory.
    03/2009        |  1001 |    100                       |  50
    Actual Report output
    Fiscal Period | Plant |  |  Begining Inventory | Ending Inventory.
    02/2009        |  1001 |                 100          | 
    03/2009        |  1001 |                                |  50
    So basically report is being split on two lines for current and previous (due to restriction in begining period : Offset =-1 on period).
    Question is how to achieve both begining and ending inventory for a period in same line.
    Thanks in avdance for help and time
    SA

    HI Naveen
    Thanks for the reply. Non *** KF are already being used and Standard SAP model is being followed. Problem is not with back end but with frontend. Data coming on the report is fine but problem is how to show them on same line. Remember Beginning inventory for current open is ending inventory for previous month and  in SAP content there is no KF called as begining inventory. Basically data from two consecutive periods (current and previous one) needs to be on same row of report, but they are coming on different rows if we have period in drilldown by period. this makes sense but how to overcome this.
    This, We have all the correct data but facing issue while displaying that on frontend.
    Thanks
    Sorabh
    Edited by: Sorabh on Mar 23, 2009 5:01 PM

  • Javadoc Comments Begin and End Offset, Line number etc...

    Hello Everyone,
    I was wondering if there is a method that return the begin and end offsets, and line number of source code comment. I know this is possible to get the line number for Doc, MethodDoc, ConstutorDoc etc... with the position() method. I was unable to get the locations of comments corresponding to the actual source code. Also, I found that when asking for the position of constructors the value returned was that of the class, is this a known bug?
    Thanks in Advanced,
    Nick

    nkhamis wrote:
    Just out of curiosity, what do the folks at sun use for Java Parsers?They didn't need to go too far. The Java Parser must be a part of any Java compiler itself! Therefore, it is a part of any JDK. Obviously, they have some internal API of their Java parser and, I guess, Javadoc uses it to build the Java code model provided via the Doclet API. But Sun had never published the full API to their Java parser. (At least, I don't know such.) Although, it would be very useful indeed...
    FYI, a parser for a high-level programming language (like Java) is a software module that inputs a program written (by humans) as text in that language and converts it into some object representation (model) "understandable" to computer. That object representation must be a sort of tree representing all the language constructs found in the program. Typically, that tree is accessible via a certain API, which I call here a Parser API (although, other terminology may be used).
    Other software modules may use that object representation of the program for various purposes, for instance:
    - To generate an executable machine (or byte-) code by it
    - To transform the initial program in order to optimize it (this is used by compilers) or to do other things (e.g. refactoring)
    - To generate documentation (that's what Javadoc does)
    Besides generating the program object representation, another job of a parser is to provide diagnostics about various syntactical errors found in the initial program source (a well as possibly some semantic warnings).
    A parser is rather sophisticated piece of code. To develop it properly, one needs to learn first some theory about this, e.g. a formal grammar that describes the given programming language and how to deal with it. I know, there have been attempts to create some universal parsers that can be adjusted to parse any programming language (within a certain range) by specifying to them some formal grammar of that language. That topic was particularly beloved by university guys, so there must be many scientific articles about this.
    thomas.behr wrote:
    Well, if you are developing an Eclipse plugin, have you considered working with Eclipse' Abstract Syntax Tree (basically an object model for Java code) instead of the Doclet API?Interesting stuff... Looks like this might be that very Java parser API I am talking about here.
    Leonid Rudy
    [http://www.docflex.com|http://www.docflex.com]

Maybe you are looking for

  • CS4 unable to re-install

    I had CS4 Production Premium for years on my Windows Vista machine and never had any problems with it. A few weeks ago I got a new Windows 8.1 Pro desktop computer and I was able to install CS4 on the new computer with no problem, and I opened severa

  • Issue In posting date and Due Date

    Hello All, my client is creating a GRPO and manually changing the Posting, And doc date. Then by using Copy to utility he is creating A/P Invoices There system automatically shows the Posting date, Document Date as of current date(That is what system

  • Why does my iChat video only run at one frame per second?

    When I connect to anyone on iChat my video runs at only about one frame per second. When others connect to me their video is much faster. This hasn't been a problem in the past - even with other Internet apps running when I'm using iChat. Could this

  • Two problems with custom kernel

    I get two problems with my custom kernel that is not using initrd and otherwise working fine: 1) initscripts does not print anything, i.e., I see the kernel messages and after a short while the login prompt. It seems to start the daemons, however, si

  • Any way to call function from impdp except remap_data?

    HI Friends, I have a requirement of load prd data into stage by masking some sensitive columns.Iam using impdp of datapump utility to load data.iam using remap_data option to call mask functions.But remap_data option is supporting upto 10 columns. we