List of usage examples for java.util Date Date
public Date()
From source file:common.ClassUtils.java
public static void main(String args[]) { Person p1 = new Person("yejing", 27, new Date(), 6500.0); PersonForm form = new PersonForm("yejing", 27, "2015-03-12", 6500.0); Person p2 = new Person(); copyBean(form, p2);//from ww w. jav a2 s .com System.out.println(p2); copyProperty(p2, "birthday", "2015-03-11"); copyProperty(p2, "name", "??"); System.out.println(p2); }
From source file:com.redhat.poc.jdg.bankofchina.function.TestCase411RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine;// ww w . jav a2 s .c o m Options options = new Options(); options.addOption("s", true, "The start csv file number option"); options.addOption("e", true, "The end csv file number option"); BasicParser parser = new BasicParser(); parser.parse(options, args); commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("s")) { String start = commandLine.getOptionValue("s"); if (start != null && start.length() > 0) { csvFileStart = Integer.parseInt(start); } } if (commandLine.hasOption("e")) { String end = commandLine.getOptionValue("e"); if (end != null && end.length() > 0) { csvFileEnd = Integer.parseInt(end); } } } System.out.println( "%%%%%%%%% csv ?, ?, ?(ms)," + new Date().getTime()); for (int i = csvFileStart; i <= csvFileEnd; i++) { new TestCase411RemoteMultiThreads(i).start(); } }
From source file:nhs.spring.integration.App.java
public static void main(String... args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "spring-integration-context.xml"); GameMessageHandler gameHandler = new GameMessageHandler(); GameGenerator gameGenerator = context.getBean(GameGenerator.class); context.start();//from w w w .j a va 2 s. c om //MessageChannel input = context.getBean("input-channel", MessageChannel.class); //PollableChannel output = context.getBean("output-channel", PollableChannel.class); QueueChannel qChannel = context.getBean("game-channel", QueueChannel.class); PollingConsumer gameConsumer = new PollingConsumer(qChannel, gameHandler); gameConsumer.setReceiveTimeout(RECEIVE_TIMEOUT); gameConsumer.setBeanFactory(context); // Set up the poller using periodic trigger PeriodicTrigger periodicTrigger = new PeriodicTrigger(1000); periodicTrigger.setInitialDelay(5000); periodicTrigger.setFixedRate(false); PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(periodicTrigger); pollerMetadata.setMaxMessagesPerPoll(3); gameConsumer.setPollerMetadata(pollerMetadata); // Starts the polling consumer in the other thread gameConsumer.start(); Date today = new Date(); // Generates messages and sends to the channel Game game = gameGenerator.generateGame("League of legend", "Riot Games", today, "Tom", "Michael", "AOS"); qChannel.send(MessageBuilder.withPayload(game).build()); /* PublishSubscribeChannel pubsubChannel = null; pubsubChannel.subscribe(gameHandler); input.send(MessageBuilder.withPayload("Spring Integration / Hello NHS").build()); Message<?> reply = output.receive(); System.out.println("Received :" + reply); */ }
From source file:com.yahoo.dba.tools.myperfserver.App.java
public static void main(String[] args) throws Exception { //-p --port 9090 //-r --webcontextroot webapps //-l --logpath logpath //-w --war webapp war file name CommandLineParser parser = new GnuParser(); Options options = new Options(); options.addOption("j", "jettyHome", true, "Jetty home, if not set, check system property jetty.home, then default to current Dir"); options.addOption("p", "port", true, "http server port, default to 9090."); options.addOption("c", "webcontextroot", true, "web app url root context, defaul to /"); options.addOption("l", "logpath", true, "log path, default to current directory."); options.addOption("w", "warfile", true, "war file name, default to myperf.war."); options.addOption("k", "workdir", true, "work directory for jetty, default to current dir."); System.out.println(new Date() + " Usage: java -classpath ... com.yahoo.dba.tools.myperfserver.App -j jettyhome -p port -c webcontextroot -k workingDir -l logpath -w war_file"); App myServer = new App(); try {/* www . jav a 2 s . c o m*/ // parse the command line arguments CommandLine line = parser.parse(options, args); // validate that block-size has been set if (line.hasOption("p")) { try { myServer.setPort(Short.parseShort(line.getOptionValue("p"))); } catch (Exception ex) { } } if (line.hasOption("c")) { String val = line.getOptionValue("c"); if (val != null && !val.isEmpty()) myServer.setContextPath(val); } if (line.hasOption("l")) { String val = line.getOptionValue("l"); if (val != null && !val.isEmpty()) myServer.setLogPath(val); } if (line.hasOption("w")) { String val = line.getOptionValue("w"); if (val != null && !val.isEmpty()) myServer.setWarFile(val); } if (line.hasOption("k")) { String val = line.getOptionValue("k"); myServer.setWorkDir(val); } if (line.hasOption("j")) { String val = line.getOptionValue("j"); if (val != null && !val.isEmpty()) myServer.setJettyHome(val); } } catch (ParseException exp) { System.out.println("Unexpected exception:" + exp.getMessage()); } System.setProperty("logPath", myServer.getLogPath()); PID_FILE = myServer.getWarFile().substring(0, myServer.getWarFile().indexOf('.')) + ".pid"; int historyPid = getHistoryPid(); if (historyPid >= 0) { System.out.println(new Date() + " *************************** WARNING *********************"); System.out .println(PID_FILE + " exists. Possibly another instance is still running. PID = " + historyPid); System.out.println(new Date() + " *************************** WARNING *********************"); } if (myServer.startServer()) { pid = getPid(); writePid(); myServer.waitForInterrupt(); removePid(); } else System.out.println("Server not started."); }
From source file:mecard.MetroService.java
public static void main(String[] args) { // First get the valid options Options options = new Options(); // add t option c to config directory true=arg required. options.addOption("c", true, "configuration file directory path, include all sys dependant dir seperators like '/'."); // add t option c to config directory true=arg required. options.addOption("v", false, "Metro server version information."); try {// w ww . j av a2 s. com // parse the command line. CommandLineParser parser = new BasicParser(); CommandLine cmd; cmd = parser.parse(options, args); if (cmd.hasOption("v")) { System.out.println("Metro (MeCard) server version " + PropertyReader.VERSION); } // get c option value String configDirectory = cmd.getOptionValue("c"); PropertyReader.setConfigDirectory(configDirectory); } catch (ParseException ex) { // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, null, ex); System.out.println( new Date() + "Unable to parse command line option. Please check your service configuration."); System.exit(799); } Properties properties = PropertyReader.getProperties(ConfigFileTypes.ENVIRONMENT); String portString = properties.getProperty(LibraryPropertyTypes.METRO_PORT.toString(), defaultPort); try { int port = Integer.parseInt(portString); serverSocket = new ServerSocket(port); } catch (IOException ex) { String msg = " Could not listen on port: " + portString; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg + ex.getMessage()); } catch (NumberFormatException ex) { String msg = "Could not parse port number defined in configuration file."; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg + ex.getMessage()); } while (listening) { try { new SocketThread(serverSocket.accept()).start(); } catch (IOException ex) { String msg = "unable to start server socket; either accept or start failed."; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg); } } try { serverSocket.close(); } catch (IOException ex) { String msg = "failed to close the server socket."; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg); } }
From source file:com.redhat.poc.jdg.bankofchina.function.TestCase413RemoteMultiThreads.java
public static void main(String[] args) throws Exception { CommandLine commandLine;/*from ww w . j av a2 s . c o m*/ Options options = new Options(); options.addOption("s", true, "The start csv file number option"); options.addOption("e", true, "The end csv file number option"); BasicParser parser = new BasicParser(); parser.parse(options, args); commandLine = parser.parse(options, args); if (commandLine.getOptions().length > 0) { if (commandLine.hasOption("s")) { String start = commandLine.getOptionValue("s"); if (start != null && start.length() > 0) { csvFileStart = Integer.parseInt(start); } } if (commandLine.hasOption("e")) { String end = commandLine.getOptionValue("e"); if (end != null && end.length() > 0) { csvFileEnd = Integer.parseInt(end); } } } System.out.println( "%%%%%%%%% csv ?, ?, ?(ms)," + new Date().getTime()); for (int i = csvFileStart; i <= csvFileEnd; i++) { new TestCase413RemoteMultiThreads(i).start(); } }