Created
April 21, 2018 16:37
-
-
Save thorntonrose/f1c5428a921184774545ae1cb0bd5f07 to your computer and use it in GitHub Desktop.
Convert long time value to Java or ISO string format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.util.* | |
import java.text.* | |
def cli = new CliBuilder(usage: "ConvertLongTime [options] <time>") | |
cli._(longOpt: "iso", "ISO format") | |
def opts = cli.parse(args) | |
if (!opts) { return } | |
if (!opts.arguments()) { | |
cli.usage() | |
return | |
} | |
def time = new Date(opts.arguments()[0] as long) | |
println (opts.iso ? new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SZ").format(time) : time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment