[JAVA] AWS Lambda timezone change

Under development ...

My boss pointed out that the time stamp on the DB is out of sync. It was the development of an API that goes to write to the DB on EC2 in response to the request received by Lambda, but when I confirmed it, it was certainly 9 hours off ...

Cause investigation

Why is the region set to Tokyo? I found this article when I searched variously. Set AWS lambda time zone to Tokyo | hacknote

The article seems to be before the release of the Tokyo region, but even if the region is set to Tokyo, for some reason only the time zone shifts ... process.env.TZ = 'Asia/Tokyo' It seems that I should insert this script, but unfortunately it was developed in Java, so I could not use it.

solution

So what should I do? From the Lambda console, go down to Functions → a specific function, and at the bottom of the Code tab *** Key *** and *** in *** Environment variables *** It seems that you can enter ** TZ ** and ** Asia / Tokyo ** in Value *** respectively.

a2326702-2c92-cae9-cc9c-d828ce8a6438.png

As a result of the test, it was output safely in Japan time. I was addicted to a simple place, so it also serves as a memorandum.

Recommended Posts

AWS Lambda timezone change
Build AWS Lambda with Quarkus
Is Java on AWS Lambda slow?
Hello World on AWS Lambda + Java
Run C binaries on AWS Lambda
Change the default timezone for the rails app
Try running Word2vec model on AWS Lambda
AWS Lambda with Java starting now Part 1
How to change the timezone on Ubuntu