List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:com.sammyun.util.DateUtil.java
/** * ?datas,datas?0??datasdatas0??datas/*from w w w. j av a 2 s .com*/ * * @param ? * @return */ public static Date getDate(int datas) { GregorianCalendar calendar = new GregorianCalendar(); calendar.add(GregorianCalendar.DATE, datas); String begin = new java.sql.Date(calendar.getTime().getTime()).toString(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date beginDate = null; try { beginDate = sdf.parse(begin); } catch (ParseException e) { e.printStackTrace(); } return beginDate; }
From source file:com.sammyun.util.DateUtil.java
/** * // ww w . ja va 2s . c o m * * @param year String * @return day int */ public static int getDayFromYear(String year) { SimpleDateFormat format = new SimpleDateFormat(year_format); Date date; int day = 0; try { date = format.parse(year); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); day = calendar.getActualMaximum(Calendar.DAY_OF_YEAR); } catch (ParseException e) { e.printStackTrace(); } return day; }
From source file:com.sammyun.util.DateUtil.java
public static String obtainMonth(String dateStr, int m) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String str = ""; try {//from w ww .j a v a 2 s . c o m Date d1 = df.parse(dateStr); Calendar g = Calendar.getInstance(); g.setTime(d1); g.add(Calendar.MONTH, m); Date d2 = g.getTime(); str = df.format(d2); str = str.replace("-", ""); } catch (ParseException e) { e.printStackTrace(); } return str; }
From source file:com.sammyun.util.DateUtil.java
/** * beginDatedatas,datas?0??datasdatas0??datas * //from w w w . ja v a 2s. c o m * @param ? * @return */ public static Date getDate(Date beginDate, int datas) { Calendar beginCal = Calendar.getInstance(); beginCal.setTime(beginDate); GregorianCalendar calendar = new GregorianCalendar(beginCal.get(Calendar.YEAR), beginCal.get(Calendar.MONTH), beginCal.get(Calendar.DATE)); calendar.add(GregorianCalendar.DATE, datas); String begin = new java.sql.Date(calendar.getTime().getTime()).toString(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date endDate = null; try { endDate = sdf.parse(begin); } catch (ParseException e) { e.printStackTrace(); } return endDate; }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);/*from w w w. j ava 2 s . c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); try { s.commitEdit(); } catch (ParseException e) { e.printStackTrace(); } }
From source file:Main.java
public TimeFormatter() { try {//from w w w.j ava2 s. co m setMask("##/##/####"); setPlaceholderCharacter('0'); setAllowsInvalid(false); setOverwriteMode(true); } catch (ParseException e) { e.printStackTrace(); } }
From source file:Main.java
private void initComponents() { JFrame frame = new JFrame("JFormattedTextField Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MaskFormatter mask = null;/*from w w w . j a v a2 s. c o m*/ try { mask = new MaskFormatter("##h##min##s");// the # is for numeric values mask.setPlaceholderCharacter('#'); } catch (ParseException e) { e.printStackTrace(); } final JFormattedTextField timeField = new JFormattedTextField(mask); // ActionListener for when enter is pressed timeField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Object source = ae.getSource(); if (source == timeField) { // parse to a valid time here System.out.println(timeField.getText()); } } }); frame.add(timeField); frame.pack(); frame.setVisible(true); }
From source file:org.openmrs.module.billing.web.controller.billingqueue.PatientSearchForBillingQueueController.java
@RequestMapping(method = RequestMethod.GET) public String main(@RequestParam(value = "date", required = false) String dateStr, @RequestParam(value = "searchKey", required = false) String searchKey, @RequestParam(value = "currentPage", required = false) Integer currentPage, Model model) { BillingService billingService = Context.getService(BillingService.class); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Date date = null;/*from w w w .java 2 s . c o m*/ try { date = sdf.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } List<PatientSearch> patientSearchResult = billingService.searchListOfPatient(date, searchKey, currentPage); currentPage = 1; int total = patientSearchResult.size(); PagingUtil pagingUtil = new PagingUtil(BillingConstants.PAGESIZE, currentPage, total); model.addAttribute("pagingUtil", pagingUtil); model.addAttribute("patientList", patientSearchResult); model.addAttribute("date", dateStr); return "/module/billing/queue/searchResult"; }
From source file:org.openmrs.module.billing.web.controller.billingqueue.ListOfOrderController.java
@RequestMapping(method = RequestMethod.GET) public String main(Model model, @RequestParam("patientId") Integer patientId, @RequestParam(value = "date", required = false) String dateStr) { BillingService billingService = Context.getService(BillingService.class); PatientService patientService = Context.getPatientService(); Patient patient = patientService.getPatient(patientId); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Date date = null;/*from w w w .ja va2 s . c o m*/ try { date = sdf.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } List<OpdTestOrder> listOfOrders = billingService.listOfOrder(patientId, date); // Kesavulu loka 25-06-2013, Add Patient Details on the page where Order ID is clicked HospitalCoreService hospitalCoreService = Context.getService(HospitalCoreService.class); PatientSearch patientSearch = hospitalCoreService.getPatientByPatientId(patientId); model.addAttribute("patientSearch", patientSearch); model.addAttribute("listOfOrders", listOfOrders); //model.addAttribute("serviceOrderSize", serviceOrderList.size()); model.addAttribute("patientId", patientId); model.addAttribute("date", dateStr); return "/module/billing/queue/listOfOrder"; }
From source file:cn.cug.laboratory.convertor.StringToDateConvertor.java
@Override public Date convert(String source) { //(yyyy-MM-dd HH:mm:ss)?? String pattern = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(pattern); //???//from ww w .ja v a2 s. c om try { return sdf.parse(source); } catch (ParseException e) { e.printStackTrace(); } //?? return null; }