Unable to set text when set a time by getting timezone (Pacific Standard Time (PST))


Can someone help me please, I want to input a time for the PST timezone. I used the code below and am getting an error "Unable to Set text.

But when I removed this .setTimeZone(TimeZone.getTimeZone(“PST”)), I successfully inputted the time but it’s a local time.

My goal is to set a Pacific Standard Time

Thank you!

You are hiding your code too much. We can not understand what you are doing. If you want to be advised, please disclose more.

Please show your test case which printed the local time.

Hi @kazurayam I Apologize, I just want to correct my statement above, So I am getting the local time when I used the code on the screenshot below.

PS: This is only my code when I set a time to the object.

I don’t have an idea what will be the easiest way to input PST time

  1. If possible convert the local time to Pacific Standard Time. or
  2. I’ll get the timezone instead to convert the time.

Thank you!

SimpleDateFormat, Calendar, … you should not use these old Java classes any more. These old classes do not support the concept of “time zone”.

You need to study the Java8 Date/Time API. See

You would want to use ZonedDateTime, ZoneId and ZoneOffset.

You need to find out how to express “Pacific Standard Time” as ZoneId, which is 8 hours behind the Coordiated Universal Time (UTC).


thanks @kazurayam for always helping me. This is a good reference. I’ll update this thread once I successfully get the PST.

1 Like

Hi @kazurayam it’s working now. I used the code below Thank you so much!!

Need to import: import java.time.*;

1 Like