If you ignore the "best by" label on UHT milk, it can easily (safely) last 8 months. Especially if you store it at 32/33° F.
But more practically, there are different types of containers for UHT milk hermetically sealed to different extents. The more expensive kinds can last years. The US Military says 10 months for "normal" UHT milk stored under "normal" conditions [0]. The more expensive kinds can go much longer.
[0]: https://www.dla.mil/Troop-Support/Subsistence/Operational-ra...