List of usage examples for java.util Date getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
public static void main(String[] args) throws Exception { Date d = new Date(); Class cls = d.getClass(); System.out.println("Time = " + d.toString()); Object obj = cls.newInstance(); System.out.println("Time = " + obj); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); Package pack = date.getClass().getPackage(); String packageName = pack.getName(); System.out.println("Package Name = " + packageName); }
From source file:com.swingtech.commons.util.ClassUtil.java
/** * NOTE: When using this to print an object it will not display the * primitive type boolean. Must use the wrapper class. All other primitives * work fine./*w ww . jav a 2 s .c o m*/ * * NOTE: If an int value has a 0 it won't display. * * NOTE: Object must have a public constructor. * * @param object * @return */ public static String getXMLForObject(final Object object) { ByteArrayOutputStream baos = null; XMLEncoder e = null; baos = new ByteArrayOutputStream(); e = new XMLEncoder(new BufferedOutputStream(baos)); e.setPersistenceDelegate(Date.class, new PersistenceDelegate() { @Override protected Expression instantiate(final Object oldInstance, final Encoder out) { final Date date = (Date) oldInstance; final Long time = new Long(date.getTime()); return new Expression(date, date.getClass(), "new", new Object[] { time }); } }); e.setPersistenceDelegate(BigDecimal.class, new PersistenceDelegate() { @Override protected Expression instantiate(final Object oldInstance, final Encoder out) { final BigDecimal bigDec = (BigDecimal) oldInstance; final double doubleVal = bigDec.doubleValue(); return new Expression(bigDec, bigDec.getClass(), "new", new Object[] { new Double(doubleVal) }); } }); e.writeObject(object); e.close(); return baos.toString(); }
From source file:org.terasoluna.gfw.functionaltest.app.date.DateController.java
@RequestMapping(value = "1_3", method = RequestMethod.GET) public String serverTimeReturn_01_03(Model model) { model.addAttribute("firstExpectedDate", new java.util.Date()); java.util.Date date = dateFactory.newDate(); model.addAttribute("serverTime", date); model.addAttribute("type", date.getClass()); model.addAttribute("lastExpectedDate", new java.util.Date()); return "date/dateDisplay"; }
From source file:org.terasoluna.gfw.functionaltest.app.date.DateController.java
@RequestMapping(value = "2_3", method = RequestMethod.GET) public String dbFixationTimeReturn_02_03(Model model) { java.util.Date date = jdbcFixedDateFactory.newDate(); model.addAttribute("serverTime", date); model.addAttribute("type", date.getClass()); return "date/dateDisplay"; }
From source file:org.terasoluna.gfw.functionaltest.app.date.DateController.java
@RequestMapping(value = "3_3", method = RequestMethod.GET) public String adjustedDateReturn_03_03(Model model) { model.addAttribute("firstExpectedDate", new java.util.Date()); java.util.Date date = msecJdbcAdjustedDateFactory.newDate(); model.addAttribute("serverTime", date); model.addAttribute("type", date.getClass()); model.addAttribute("lastExpectedDate", new java.util.Date()); return "date/dateDisplay"; }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationPropertiesWithDateArray() { ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray(); Date dateValue = config.dateArray[0]; GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); Date date = new Date(calendar.getTimeInMillis()); assertEquals(Date.class, dateValue.getClass()); assertEquals(date.getTime(), dateValue.getTime()); assertEquals(3, config.dateArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java
@Test public void testConfigurationXMLWithDateArray() { ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray(); Date dateValue = config.dateArray[0]; GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); Date date = new Date(calendar.getTimeInMillis()); assertEquals(Date.class, dateValue.getClass()); assertEquals(date.getTime(), dateValue.getTime()); assertEquals(3, config.dateArray.length); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationPropertiesWithDateList() { ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList(); Date dateValue = config.dateList.get(0); GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); Date date = new Date(calendar.getTimeInMillis()); assertEquals(Date.class, dateValue.getClass()); assertEquals(date.getTime(), dateValue.getTime()); assertEquals(3, config.dateList.size()); }
From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java
@Test public void testConfigurationXMLWithDateList() { ConfigurationXMLWithList config = prepareConfigurationXMLWithList(); Date dateValue = config.dateList.get(0); GregorianCalendar calendar = new GregorianCalendar(2012, Calendar.AUGUST, 14, 18, 10, 50); Date date = new Date(calendar.getTimeInMillis()); assertEquals(Date.class, dateValue.getClass()); assertEquals(date.getTime(), dateValue.getTime()); assertEquals(3, config.dateList.size()); }