I track my trips using TripIt, so I know the exact dates. It was Jan 2014 and I was flying NH from SIN to NRT to SFO. I departed SIN at 12:55AM and arrived at NRT at 8:35AM. I am pretty sure that I went to through security and on to the NH lounge in the departure area to take a shower and have some breakfast, before going through passport control and out to Narita to visit the Shinshō-ji Temple. My departure from NRT to SFO was at 5:25PM. I know have done a similar thing in TPE, where I visited the BR lounge before going out to the city. But I am pretty I have done it in NRT and also BKK as well.
In 2014 I was a US citizen. However, back in 2000 I was flying from SFO to NRT to CMB as a Sri Lankan citizen with a US green card and I got a shore pass at NRT because I had an overnight layover at NRT.