Created
July 13, 2017 12:23
-
-
Save midoribashikk/5a9284bba9e5f8c4c3aa24f86da2a66c to your computer and use it in GitHub Desktop.
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 java.util.Calendar; | |
import java.text.SimpleDateFormat; | |
public class UnixTimeConverter { | |
public String conv(String utime) { | |
String retstr = ""; | |
try { | |
Calendar cal = Calendar.getInstance(); | |
cal.setTimeInMillis(Long.parseLong(utime) * 1000L); | |
retstr = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z").format(cal.getTime()); | |
} catch (NumberFormatException e) { | |
retstr = "<error...>"; | |
} | |
return retstr; | |
} | |
public static void main(String[] args) { | |
UnixTimeConverter obj = new UnixTimeConverter(); | |
if (args.length>0) { | |
for (String arg : args) { | |
System.out.println(obj.conv(arg)); | |
} | |
} else { | |
System.out.println("<no input...>"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment