I have a CGI script that will convert a given string to a date/time using the unix date
command. I'm looking for a format that can easily be embedded to a URL without the need for escaping with a %20
. The client that is building the date/time into the URL does not have a conversion to unix time (seconds since epoch) and does not have a way to convert to the offset from zulu (ISO8601 will not work). However, it is possible to reformat the date/time used to build the URL in many other ways.
Are there any other options to build a datetime in a non-spaced format?
The dates appear as, mm/dd/yyyy in the U.S. and as, dd/mm/yyyy outside the U.S. where mm is the month, dd is the day, and yyyy is the year. The time is displayed as, hh:mm:ss AM/PM, where hh is the hour, mm is minutes, and ss is seconds.
The T is just a literal to separate the date from the time, and the Z means "zero hour offset" also known as "Zulu time" (UTC). If your strings always have a "Z" you can use: SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss. SSS'Z'", Locale.US); format.
$ date "+%F-%T"
2010-10-25-16:23:14
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With