Integer.parseInt has a funny side effect though. It will convert 000 to 0, 03 to 3 and so on.
Code:
import java.util.Date; // mandatory only for the "current date and time" part
public class prob4
{
public static void main(String args[])
{
String ArgumentFromCommandLine = "";
int time = 0;
// exit program if the supplied argument is not an integer OR
// if no or too many arguments were supplied
if (args.length == 1) {
try {
ArgumentFromCommandLine = args[0];
time = Integer.parseInt(ArgumentFromCommandLine);
} catch (NumberFormatException e) {
System.err.println("Argument " + args[0] + " must be an integer.");
System.exit(1);
}
}
else {
System.err.println("No or too many arguments were supplied.");
System.exit(1);
}
// collect all values
Long utms = System.currentTimeMillis(); // UNIX time in milliseconds
Long uts = utms / 1000; // UNIX time in seconds
Long utd = uts / 86400; // UNIX time in days
Date dateandtime = new Date(); // Current date and time, default format
// print requested value
switch ( time )
{
case 0:
System.out.println("Milliseconds since 1970: " + utms);
break;
case 1:
System.out.println("Seconds since 1970: " + uts);
break;
case 2:
System.out.println("Days since 1970: " + utd);
break;
case 3:
System.out.println("Current date and time: " + dateandtime);
break;
default:
System.out.println("Invalid");
}
}
}
This User Gave Thanks to junior-helper For This Post:
Hello everybody,
I have a problem about running a java class with a cron :
I have Cron.txt file which has :
0,5,10,15,20,25,30,35,40,45,50,55 * * * * CronJava.txt
I have CronJava.txt wihich has :
cd ias/j2ee/SapAktarim/applications/SapAktarim/SapAktarim/WEB-INF/classes/;java -classpath... (3 Replies)
Like class loader in java, can we make a function loader in shell script, for this can someone throw some light on how internally bash runs a shell script , what happenes in runtime ...
thanks in advance.. (1 Reply)
Hi,
Is it possible to call the constructur of a java class in a shell script?
I know you can call static methods, but can you also call the constructor?
tnx. (1 Reply)
Hi, everyone:
I'm trying to connect to DB using JDBC on fedora. I have successfully installed jdk and it's ok to run common java program.
The environment variables:
JAVA_HOME=/installed/mycoy/jdk1.6.0
PATH=$JAVA_HOME/bin:$PATH... (3 Replies)
Is anyone know how to write a class in separate file? While method does it needs to be contained in a printwriter class? Can I have the format of the printwriter class as a reference? Thanks a lot. (1 Reply)
Hi, I need help to Link array from one class to another class
Firstly CSVParser Class what it did is load csv file and store into array
Secondly WarehouseItem where each record is store
How can I get a list of array that I load to CSVParser Class and store them to WarehouseItem and... (0 Replies)
Hi all!
I am trying to register a device in an existing device class, but I am
having trouble getting the pointer to an existing class.
I can create a class in a module, get the pointer to it and then use
it to register the device with:
*cl = class_create(THIS_MODULE, className);... (0 Replies)
I am trying to verify my understanding on setter and getter on java class with this example:
//MaximumFinder2.java
import java.util.Scanner;
public class MaximumFinder2
{
public static void main (String args)
{
Scanner input = new Scanner(System.in);
... (6 Replies)
Discussion started by: yifangt
6 Replies
LEARN ABOUT CENTOS
abrt-action-analyze-java
ABRT-ACTION-ANALYZ(1) ABRT Manual ABRT-ACTION-ANALYZ(1)NAME
abrt-action-analyze-java - Calculate and save UUID & DUPHASH and determine the level of usability for reporting of a Java stack trace.
SYNOPSIS
abrt-action-analyze-java [-v] [-d DIR] [-o] [-f FILE]
DESCRIPTION
The tool reads the file named backtrace from a problem data directory, processes it and generates a universally unique identifier (UUID).
Then it saves this data as new element uuid. It also checks whether the stack trace contains a remote address in any of its frames and if
so it creates not-reportable element whose contents explains why the stack trace should not be reported into a bug tracking system.
Integration with ABRT events
abrt-action-analyze-java can be used to generate the UUID & DUPHAS of a newly saved Java stack trace.
EVENT=post-create analyzer=Java abrt-action-analyze-java
OPTIONS -d DIR
Path to a problem directory. The tool reads the backtrace from stdin when neither this option nor -f is provided.
-f FILE
Path to a stack trace. The tool reads the backtrace from stdin when neither this option nor -d is provided.
-o
Print the result to stdout.
-v
Be more verbose. Can be given multiple times.
AUTHORS
o ABRT team
abrt-java-connector 01/19/2014 ABRT-ACTION-ANALYZ(1)