1 Reply Latest reply on May 17, 2006 11:12 AM by Newsgroup_User

    Extend Date Class Flex 2 Beta 3

    Chester_Copperpot
      I want to add some methods to the Date class, like beginOfMonth / endOfMonth which returns the first millisecond and last millisecond of the month respectively. I thought I could just extend the Date class, but I can't becuase it is "final" is there a good way to do this?

      Thanks,

      Chris
        • 1. Re: Extend Date Class Flex 2 Beta 3
          Level 7
          Hi Chester -

          For what you want to do, it doesn't sound like sub-classing Date is really
          necessary (and as you pointed out, is not possible). I'd suggest you just
          write some utility functions like beginOfMonth(), endOfMonth(), etc and
          place them in a utility class that you can use at any time.

          You could write a wrapper class that facades all the functionality in the
          Date class as well as adding in your new methods, but now you cannot pass an
          instance of your wrapper class to anything that expects a Date object.

          Hope this helps -

          Deepa Subramaniam
          Flex SDK Developer


          "Chester Copperpot" <webforumsuser@macromedia.com> wrote in message
          news:e4fm2g$lo0$1@forums.macromedia.com...
          >I want to add some methods to the Date class, like beginOfMonth /
          >endOfMonth
          > which returns the first millisecond and last millisecond of the month
          > respectively. I thought I could just extend the Date class, but I can't
          > becuase it is "final" is there a good way to do this?
          >
          > Thanks,
          >
          > Chris
          >