Is it posible to get how many day's has one specific month with Calendar

Can any help me how to get how many days one month has. Like february 28, and sometimes 29.

There is no way to do this within Calendar directly, the Gregorian calendar has a private method that does this, shame its not public.
You would need to do something like,
import java.util.*;
public class MyCalendar extends GregorianCalendar {
    private static final int MONTH_LENGTH[]
        = {31,28,31,30,31,30,31,31,30,31,30,31}; // 0-based
    private static final int LEAP_MONTH_LENGTH[]
        = {31,29,31,30,31,30,31,31,30,31,30,31}; // 0-based
    /** Creates a new instance of MyCalendar */
    public MyCalendar() {
    public final int monthLength(int month, int year) {
        return isLeapYear(year) ? LEAP_MONTH_LENGTH[month] : MONTH_LENGTH[month];
    public static void main(String argv[]){
        MyCalendar cal = new MyCalendar();
        System.out.println( "There are " + cal.monthLength(cal.get(Calendar.MONTH),cal.get(Calendar.YEAR)) + " days this month.");
}

Similar Messages

  • How do I calculate how many days are left in a month?

    I'm trying to figure out a way to do this to make a payment apportion using the days left. One of the problems lies in the date being dynamic, since I'm using "whatever today's date is" and it actualizes by day. Any help will be appreciated.

    Using some reusable document level scripts for general functions like getting a field object, a date object from a string, and the number of days in a month one could have a script like:
    // document level functions;
    function GetField(cName) {
    // return the field object for named field;
    // with error checking;
    var oField = this.getField(cName); // get field object;
    // test for error getting field;
    if(oField == null){
    // error accessing field;
    app.alert("Error accessing field " + cName);
    // return field object;
    return oField;
    } // end GetField object;
    function GetDateObject(cFormat, cDate) {
    // get the date object for date cDate with format of cFormat;
    var oDate = util.scand(cFormat, cDate);
    if(oDate == null) {
    app.alert("Error converting date " + cDate + " with format " + cFormat, 0, 0);
    return oDate;
    } // end GetDateObject function;
    function DaysInMonth(cFormat, cDate) {
    // return last day of month;
    var oDate = GetDateObject(cFormat, cDate);
    var StartDate = oDate.getDate(); // get day from date object;
    // set date object to 1st of next month;
    oDate.setMonth(oDate.getMonth() + 1, 1);
    // set date object to pervious date;
    oDate.setDate(oDate.getDate() - 1);
    // get last day of month;
    return oDate.getDate();
    } // end DaysInMonth function;
    // end document level functions;
    // custom calculation script;
    // check for needed functions;
    if(typeof GetField != "function") app.alert("Missing GetField function!", 0, 0);
    if(typeof GetDateObject != "function") app.alert("Missing GetDateObject function!", 0, 0);
    if(typeof DaysInMonth != "function") app.alert("Missing DaysInMonthh function", 0, 0);
    // some specific data to get value from field;
    var cDateName = "MyDateField"; // name of date field;
    var cDateFormat = "dd-mmm-yyyy"; // format of date field;
    // end specific data;
    // get date field object;
    var oDateField = GetField(cDateName);
    // get the string value for the date;
    var cDateValue = oDateField.value;
    // convert date value to date object;
    var oDate = GetDateObject(cDateFormat, cDateValue);
    var nStartDate = oDate.getDate(); // start date for computation;
    // the day for the last day of the month
    var nLastDayOfMonth = DaysInMonth(cDateFormat, cDateValue);
    var DaysToEndOfMonth = nLastDayOfMonth - nStartDate;
    event.value = DaysToEndOfMonth;
    // end custom calculation script;

  • How many days will an apple store hold my pc if orderred with 'personal pickup' delivery?

    I'll buy an MBA (non-base version) and i'd like it to be delivered to one of chicago's apple stores.
    My problem is that i'll stay in chicago for 2 days and any delay on my mac delivery would lead to a big problem for me.
    My mac should take 12 days to be delivered so i was thinking about placing the order 15 days before my stay in chicago, just to be sure to find it.
    That's why i'm wondering: how many days apple stores hold orders delivered with the 'personal pickup' option before sending them back to the factory?

    I'll buy an MBA (non-base version) and i'd like it to be delivered to one of chicago's apple stores.
    My problem is that i'll stay in chicago for 2 days and any delay on my mac delivery would lead to a big problem for me.
    My mac should take 12 days to be delivered so i was thinking about placing the order 15 days before my stay in chicago, just to be sure to find it.
    That's why i'm wondering: how many days apple stores hold orders delivered with the 'personal pickup' option before sending them back to the factory?

  • In how many days i can get i-Phone 6, if i order it online from apple store, Tulsa

    In how many days i can get i-Phone 6, if i order it online from apple store, Tulsa,OK, USA

    In no days at all because you will not be able to order it from the Apple store online if you do not live in the USA and by your user name I am assuming that you don't live in the US?
    The US Apple store online will not ship outside the US, so wait until you can purchase the iPhone 6 in India or wherever you are and buy it then.
    Anyway, pre-orders for the iPhone started last Friday, so pre-orders now are looking at an October/November delivery date, but forget that because you can't anyway.
    Wait until you can get it in your country and then buy it.

  • How many days did it take to get MB from Apple Online

    so im planning to buy a white mb from apple online store, it says 5-7 days to deliver, but i have read some users to wait up to 14 days to get a MB delivered.
    How many days did it take since you placed the order, and got your MB delivered?
    thanks!

    I CTO'd
    (configured to Order) online 17 minutes after the
    public announcement that Apple was taking orders. I
    went into the Apple store to actually look at the
    MacBook three hours later when the Apple store
    opened. The salesmen (several of them) told me then
    it would take about a week before delivery while my
    order statement said two weeks.
    The machine came Federal Express (I didn't order
    special shipping) from China within 5 working days.
    It has run perfectly from the day I got it.
    Good to hear that you are having no problems, Tim. I CTOd the same configuration (Black/120GB/2GB) last Tues and it will arrive tomorrow or Tues (shipped from China late Thurs and was in L.A .. via Anchorage and Indianapolis .. by Sat morning).
    I'll dual-boot it so I can travel without this iBook plus a WinXP machine: One MacBook will be more workable.
    Phil

  • How many days take to get a iphone

    Hello i am in Germany but i do not know german so i can not write to them, i will like to know how many days takes to get an iphone 5?

    The German Apple Store is quoting two to three weeks for all models.
    Regards.

  • How many days it takes for the epub file to get approved by apple itunes store?

    Hi,
    We are in a publishing company and now have got some work where we are converting the book to epub. We have all the basic requirement for registering for itunes store. The Printed version of the book is going to be launched on a specific day, wanted to know how many days it will take for the epub file to be approved and be made available on ibookstore provided the files is proper as per apples requirement.
    Kindly suggest.
    Thanks & Regards
    Rishi

    Ok, that's not so good for me.
    But thank you

  • How many days it will take to unlock an iphone 4s , it is locked with 02 network from England

    how many days it will take to unlock an iphone 4s , it is locked with 02 network from England. I had laready given IMEI number to concerned guys

    but one of my friend has taken my IMEI number and starte processing here from india and he got some contacts in US , the process has been already started. He told that it gonna take 3 working days to get unlocked.
    regards,
    HarisH

  • How to know active user in Ad ? & how many days from not use user id ?

    How to know active user in Ad ? & how many days from not use user id ?
    Thanks & Regards, Amol . Amol Dhaygude

    Hi Amol,
    You can use the below command from the command prompt of DC to get all the AD users who are inactive for last
    X weeks,
                                    dsquery
    user -inactive X 
    To extract the inactive user information to a CSV file use the below command,
                   dsquery user -inactive X > c:\TestFolder\InactiveUsers.csv
    NOTE: The value
    X represents number of weeks, for example if your requirement is to find the inactive users for last 90 days then the
    X value should be 13.
    Regards,
    Gopi
    JiJi Technologies

  • How many days have you waited for approval?

    I have waited for 10 days. Still "Not on 32 stores" status for all the books I uploaded.
    How many days have you waited before you get your books approved? Does the status ever changed to say "Under Review"? Will you received an email when your book get approved?
    Thanks!

    OK, I finally have 1 book - out of 8 submitted approved. So I finally have answers to my questions - hope it help others too!
    How many days have you waited before you get your books approved?
    - in this case, about 11 days. Would say 2 weeks is a good bet.
    Does the status ever changed to say "Under Review"?
    - no. It just turned the red ligh to green, and show "On 32 stores".
    Will you received an email when your book get approved?
    - no.
    Now I still looking for the answer of: can the book get updated once approved? I just submitted a major revision (and grow the book from 70+ pages to 100+ pages) and see whether this will get updated. It goes through fine in iTunes Producer.

  • How can I determine how many days are left on an evaluation Enterprise license key?

    I am using the evaluation key available for SP 2010 enterprise. However, I would like to be able to determine how many days remain before it expires.
    Is there a page/link/powershell command/etc. for getting that information?
    Thank you.

    well, I am surprised - and a bit disappointed - that there isn't powershell commands that report the situation.
    But, I can manually go through one machine to find the info, then figure out manually or via some web app when the deadline is.
    I would have thought if Microsoft wanted people to convert an eval to a commercial license so they would make the information appear on the front of central admin

  • Does Adobe Send allow you to select how many days your files can be downloaded - as with Adobe Send Now? Also, why don't I see the virus scanning message any longer with "Send" versus "Send Now"?

    Does Adobe Send allow you to select how many days your files can be downloaded - as with Adobe Send Now? Also, why don't I see the virus scanning message any longer with "Send" versus "Send Now"?

    We relied upon the "days available for download" to get people to take
    action more quickly. The "virus scanning" progress bar was simply another
    way of knowing this activity was actually taking place - unless this is
    written somewhere in the Adobe Send User Guide.....wherever that is.
    On Tue, Dec 2, 2014 at 12:09 PM, bob.treitman <[email protected]>

  • I have been requested the certificate for iOS development since 4 days ago, but the result is still pending approval. So how many days should i wait?

    i have been requested the certificate for IOS Development since 4 days ago, but the result is still pending approval. So how many days should i wait?

    1. You did not get an error message telling you that your iPhoto library was getting full. You got a message telling you that your HD was getting full, right?
    OS X needs about 10 gigs of hard drive space for normal OS operations - things like virtual memory, temporary files and so on.
    Without this space your Mac will slow down as the OS hunts for space on the disk, files will be fragmented, also slowing things down, apps will crash and the risk of data corruption - that is damage to your files, photos, music - increases exponentially.
    Your first priority is to make more space on that HD. Nothing else can be done until you do.
    Purchase an external HD and move your Photos and Music to it. Both iPhoto and iTunes can run perfectly well with the Library on an external disk.
    Your Library has been damaged from being run on an overfull disk.
    How much free space on it now?

  • Vodafone tell me that is be waiting for unlock by IMEI by Apple, how many days are necesary for it?

    I called vodafone to unlock my iphone 4 by IMEI, they told me that now they are waiting the password from Apple, how many days are necesary for it? thanks

    You don't say where you are but process is
    Carrier approves your request to unlock ?
    they instruct Apple to update their servers to release the lock which is activated via iTunes
    Depends on how fast Vodafone work and how fast Apple update their servers
    For you to activate you need to insert a non Vodafone sim  and connect to iTunes
    When Apple have updated you will get a message
    "congratulations your iPhone is now unlocked "

  • In how many days is refurbishment of iphone done?

    in how many days is refurbishment of an iphone done ?
    my iphone was not an year old and its speaker right to the dock stopped functioning twice , the first time when i took it out of the box for the first time. it was repaired but for second time they told that it cannot be repaired and it needs refurbishment but i am eager to know as in how many days shall i get my new iphone.
    ANSWER NEEDED DESPERATELY.

    Hi,
    In every database there will one profile present by default that is "DEFAULT" you can alter the resource limiit in this profile so If you set PASSWORD_LOCK_TIME parameter to "DEFAULT" then it points to the PASSWORD_LOCK_TIME value set in the DEFAULT profile.
    In your DEFAULT profile if you set PASSWORD_LOCK_TIME to 2 and then in another profile if you set PASSWORD_LOCK_TIME to default then PASSWORD_LOCK_TIME value will be 2.
    Hi guys, please specify if i am wrong.
    HTH
    regards
    Jafar

Maybe you are looking for