This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

Kum Sundarah

Greenhorn
+ Follow
since Apr 08, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
1
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kum Sundarah

While extracting from the database, all the fields are taken as string, start_date is formatted with to_char to be in this format. YYYY-MM-dd hh:mm:ss.

Based on your responses, I got that I need to convert my string to date, then convert the timezone.

I did this and it worked fine.

Date date1= new SimpleDateForat("YYYY-MM-dd hh:mm:ss").parse(StartDate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date1);

SimpleDateForat estdate = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss");

estdate.setTimeZone(TimeZone.getTimeZone("GMT"));

System.out.println(estdate.format(calendar.getTime()));  

Thanks all.
1 week ago
I need my time in GMT only. So, I infer I can use java.util.Date itself.
Also, looked at the ZonedDateTime. There it uses LocalDateTime to convert timezone.

My question primarily is how to take the resultset from a DAO- the start_date values from the database comes as EST. I need to convert each record with start_date from EST to GMT.
All examples I see show how to get the zone for Localtime. I want to pass the value from the database and convert that.

If you can modify my code and show the usage, that will help my understanding.

Thanks!
2 weeks ago
in my DAO class, I have a date field start_date that comes as YYYY-MM-DD hh:mm:ss.
In the setter method, how do I convert this from EST to GMT?

public void setStart_date(String start_date){
Calendar calendar = Calendar.getInstance();

calendar.setTime(new Date());
SimpleDateFormat fmt = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss");

fmt.setTimeZone(TimeZone.getTimeZone("GMT"));

this.start_date = fmt.format(calendar.getTime(start_date));   //Getting ERROR here
}

Getting Error: method getTime in class ajva.util.Calendar cannot be applied to given types;
reason: actual and formal argument lists differ in length.

Please suggest how to fix.
2 weeks ago