List of usage examples for java.util Date Date
public Date()
From source file:com.github.ffremont.SpringBatchApplication.java
/** * @param args the command line arguments */// w w w.j av a 2 s . c om public static void main(String[] args) { ClassPathXmlApplicationContext cpt = new ClassPathXmlApplicationContext("simple-job.xml"); cpt.start(); JobLauncher jobLauncher = (JobLauncher) cpt.getBean("jobLauncher"); Job job = (Job) cpt.getBean("partitionSimpleStepJob"); JobParameters parameter = new JobParametersBuilder().addDate("date", new Date()).toJobParameters(); try { jobLauncher.run(job, parameter); } catch (JobExecutionException ex) { LOG.error("Oups", ex); } }
From source file:config.MainClass.java
/** * @param args the command line arguments *//*www . j a va 2 s . co m*/ public static void main(String[] args) { // TODO code application logic here File file = new File("D:\\iti images\\Dish Party_6-11-2014\\IMG_5376.jpg"); byte[] bFile = new byte[(int) file.length()]; try { FileInputStream fileInputStream = new FileInputStream(file); //convert file into array of bytes fileInputStream.read(bFile); fileInputStream.close(); } catch (Exception e) { System.out.println("Error in reading the image"); } UserData data = new UserData(); data.setUserName("hasby allah"); data.setBirthday(new Date()); data.setPhone("65656"); data.setFullName("7asby allah w n3m el wakel"); data.setAddress("haram"); data.setPassword("password"); data.setImage(bFile); AbstractApplicationContext fact = new ClassPathXmlApplicationContext("SpringConfig.xml"); DaoService serviceInterface = fact.getBean(DaoService.class); serviceInterface.save(data); }
From source file:ExceptionalTest.java
public static void main(String[] args) { int i = 0;/*from www. java 2s . c o m*/ int ntry = 10000000; Stack<String> s = new Stack<String>(); long s1; long s2; // test a stack for emptiness ntry times System.out.println("Testing for empty stack"); s1 = new Date().getTime(); for (i = 0; i <= ntry; i++) if (!s.empty()) s.pop(); s2 = new Date().getTime(); System.out.println((s2 - s1) + " milliseconds"); // pop an empty stack ntry times and catch the resulting exception System.out.println("Catching EmptyStackException"); s1 = new Date().getTime(); for (i = 0; i <= ntry; i++) { try { s.pop(); } catch (EmptyStackException e) { } } s2 = new Date().getTime(); System.out.println((s2 - s1) + " milliseconds"); }
From source file:com.home.ln_spring.ch10.sample.SpringJpaAuditSample.java
public static void main(String[] args) { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load("classpath:ch10/spring-data-app-context.xml"); context.refresh();/*from w ww .j a v a2 s.c om*/ ContactAuditService auditService = context.getBean("contactAuditService", ContactAuditService.class); List<ContactAudit> contacts = auditService.findAll(); listContacts(contacts); // Add new contact System.out.println("Add new contact"); ContactAudit contact = new ContactAudit(); contact.setFirstName("John"); contact.setLastName("Smith"); contact.setBirthDate(new Date()); auditService.save(contact); contacts = auditService.findAll(); listContacts(contacts); contact = auditService.findById(41l); System.out.println(""); System.out.println("Contact with id 41: " + contact); System.out.println(""); // Update Contact System.out.println("Update contact"); contact.setFirstName("Joaquin"); //auditService.save(contact); contacts = auditService.findAll(); listContacts(contacts); // Search entry audit by number version ContactAudit oldContact = auditService.findAuditByRevision(41l, 29); System.out.println(""); System.out.println("Old Contact with id 41 and rev 1: " + oldContact); System.out.println(""); oldContact = auditService.findAuditByRevision(41l, 30); System.out.println(""); System.out.println("Old Contact with id 41 and rev 2: " + oldContact); System.out.println(""); }
From source file:AuthenticationHeader.java
public static void main(String[] args) { try {/*from w w w. j ava 2s . c om*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); JAXBContext context = JAXBContext.newInstance(AuthenticationHeader.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(header, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.hm.cs.goetz1.seminar.Main.java
public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); UserService userService = (UserService) context.getBean(UserService.class); userService.addNewUser("test@email.de", "Max", "Mustermann", "totalGeheim", new Date()); userService.changeUserPassword("test@email.de", "totalGeheim", "nochGeheimer"); context.close();//from w ww . ja va2 s . c om }
From source file:ListMObjects.java
public static void main(String[] args) { System.out.println("Executing List MObjects"); try {/*from w ww.j av a 2s .co m*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsListMObjects request = new ParamsListMObjects(); SuccessListMObjects result = port.listMObjects(request, header); JAXBContext context = JAXBContext.newInstance(SuccessListMObjects.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:GetLead.java
public static void main(String[] args) { System.out.println("Executing Get Lead"); try {/*from ww w . j a v a 2s . co m*/ URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsGetLead request = new ParamsGetLead(); LeadKey key = new LeadKey(); key.setKeyType(LeadKeyRef.EMAIL); key.setKeyValue("t@t.com"); request.setLeadKey(key); SuccessGetLead result = port.getLead(request, header); JAXBContext context = JAXBContext.newInstance(SuccessGetLead.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:DescribeMObject.java
public static void main(String[] args) { System.out.println("Executing Describe MObject"); try {// w w w . j a v a2 s .c o m URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsDescribeMObject request = new ParamsDescribeMObject(); request.setObjectName("ActivityRecord"); SuccessDescribeMObject result = port.describeMObject(request, header); JAXBContext context = JAXBContext.newInstance(SuccessDescribeMObject.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }
From source file:GetImportToListStatus.java
public static void main(String[] args) { System.out.println("Executing Get Import To List Status"); try {// ww w . j a va2 s .c om URL marketoSoapEndPoint = new URL("CHANGE ME" + "?WSDL"); String marketoUserId = "CHANGE ME"; String marketoSecretKey = "CHANGE ME"; QName serviceName = new QName("http://www.marketo.com/mktows/", "MktMktowsApiService"); MktMktowsApiService service = new MktMktowsApiService(marketoSoapEndPoint, serviceName); MktowsPort port = service.getMktowsApiSoapPort(); // Create Signature DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); String text = df.format(new Date()); String requestTimestamp = text.substring(0, 22) + ":" + text.substring(22); String encryptString = requestTimestamp + marketoUserId; SecretKeySpec secretKey = new SecretKeySpec(marketoSecretKey.getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); byte[] rawHmac = mac.doFinal(encryptString.getBytes()); char[] hexChars = Hex.encodeHex(rawHmac); String signature = new String(hexChars); // Set Authentication Header AuthenticationHeader header = new AuthenticationHeader(); header.setMktowsUserId(marketoUserId); header.setRequestTimestamp(requestTimestamp); header.setRequestSignature(signature); // Create Request ParamsGetImportToListStatus request = new ParamsGetImportToListStatus(); request.setProgramName("Trav-Demo-Program"); request.setListName("Trav-Test-List"); SuccessGetImportToListStatus result = port.getImportToListStatus(request, header); JAXBContext context = JAXBContext.newInstance(SuccessGetImportToListStatus.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(result, System.out); } catch (Exception e) { e.printStackTrace(); } }