In the US, a patent application must be filed within one year of public disclosure or offering the invention on sale or use anywhere in the world. Even trivial actions can initiate the one year time period. Public disclosure would include simple actions like casually describing the invention to a friend over dinner in a private setting.
Similarly, “public use” is considered from the date the invention was used in public, even if the public never learned about the invention. Thus, even if the invention is not disclosed to the public, but has been under “use” the statutory barrier would apply and one would have foregone their right to secure a patent after one year of such use.