The UV index varies throughout the day, climbing to a peak at midday and then dropping. A UV index of 14 means it’s 14 at midday and around half that at 10am and 2pm. It is best to get your sun when the UV index is high, because you need to spend less time in the sun.
UVB is the form of ultraviolet light that produces vitamin D in the skin. All UV penetrates water, so swimming won’t reduce the amount of vitamin D you make. However, ordinary glass absorbs UVB while letting UVA through, so you get no vitamin D benefits if a glass window is between you and the sun.
UV levels are readily available online for all countries. Here are a few useful pages:
If you want to use a sun-bed to increase your vitamin D production on cloudy days, be aware that most sun-beds do provide a mix of UVA and UVB rays, but check to be sure before you use or buy one. If you do use a sun-bed, limit your time and UVB intensity to about a third of what you would spend in the sun to avoid the risk of unnecessary skin damage and possible melanoma later in life.
For more information on all these topics, please see the MS Encyclopedia.