Obtaining a patent can take a long time. Overall the process will take several years. The full lifecycle of your patent process will generally follow these steps
The first step is to make sure that your invention is "novel." The term “prior art” essentially refers to relevant material that "was patented, described in a printed publication, or in public use, on sale, or otherwise available to the public." 35 U.S.C. §102. There are two exceptions to this rule: (1) disclosures made 1 year or less before filing, and (2) disclosures obtained from joint inventors, or the inventor himself.
Once you determine that your invention is not disclosed through prior art, it is time to start preparing your disclosures and drafting your claims. This part of the process has as much to do with your competition as it does with your invention. The total time depends on the complexity of your invention. You will need to draft your patent application to be as broad as needed to preclude competitors from copying your invention, but narrow enough so that your not patent is not invalidated during litigation. This can happen when poorly drafted patents attempt to claim too much, and end up claiming prior art that would have been obvious to a person of ordinary skill in the art. It may seem strange that your patent can be invalidated after it is awarded, but it happens alot. Proper disclosure and claim construction are critical to maintaining the value of your patent.
At some point you will want to make a decision whether or not you will file a provisional application under 35 U.S.C. §111(b), or if you will file without one. The advantage to filing a provisional application is that you can obtain a priority date on your invention without having to include your full disclosure and claims. These are very helpful in fast moving markets. They also allow you to continue development of your idea before drafting your application. While full disclosure and claims are not needed, a provisional patent must contain "a written description of the invention, and of the manner and process of making and using it, in such full, clear, concise, and exact terms as to enable any person skilled ... to make and use the same." 35 U.S.C. §112(a)
If your invention is ready, rather than filing a provisional application you can opt to file for priority examination. For an additional cost (several thousand dollars), after meeting some basic requirements you can file for priority examination which will get you a decision from the USPTO within 12 months. The average time is around 3 years. This can be a substantial gain in time.
This is the phase where your patent is reviewed by the USPTO. It can take a long time, years in most cases. In the meantime you can place the words patent pending on your invention, and if competitors are infringing, you can still recover for infringement that takes place during review, provided you actually end up getting the patent.
After obtaining your patent, there are still many things to do! If you are denied, you can consider filing a reconsideration or an appeal. You will have to pay issue fees as well as maintenance fees throughout your time of ownership. Believe it or not, even after you obtain your patent it can still be lost. Third-parties may challenge your newly issued patent under an inter partes review, a post grant review, or a derivation proceedings. All of these allow the third party to challenge one or more of your claims as unpatentable.