troubleshooting Question

help with a regular expression

Avatar of anshuma
anshumaFlag for United States of America asked on
9 Comments2 Solutions186 ViewsLast Modified:

I am passing the following argument
dateheader = "09/24/2009 15:16:32.099";
to the regular expression below

strsecond =  String.valueOf(dateheader.replaceAll(".+[\\ ]+([0-9]{1,2}):([0-9]*):([0-9]*):(.+)","$3"));

so that I can get the seconds in this case the answer should be 32. But I am getting the following output

09/24/2009 15:26:33.309

Could someone please fix the regular expression for me.

Also is there another cleaner way to handle dates. Like get the date part, year part , etc
Join our community to see this answer!
Unlock 2 Answers and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros