List of usage examples for java.util Calendar set
public final void set(int year, int month, int date)
YEAR
, MONTH
, and DAY_OF_MONTH
. From source file:one.TimeLineChart.java
private static Date date(final int day, final int month, final int year) { final Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); final Date result = calendar.getTime(); return result; }
From source file:gob.dp.simco.comun.FunctionUtil.java
public static Calendar ponerAnioMesActual(Date fecha, Date fechaActual) { try {//from w ww . ja va 2 s . c o m Calendar cActual = Calendar.getInstance(); cActual.setTime(fechaActual); Calendar cfecha = Calendar.getInstance(); cfecha.setTime(fecha); //la fecha nueva Calendar c1 = Calendar.getInstance(); c1.set(cActual.get(Calendar.YEAR), cActual.get(Calendar.MONTH), cfecha.get(Calendar.DATE)); return c1; } catch (Exception e) { return null; } }
From source file:Main.java
/** * Copy <i>only</i> date information to a new calendar. * * @param from calendar to copy from//w w w . j a va2 s . co m * @param to calendar to copy to */ public static void copyDateTo(Calendar from, Calendar to) { int year = getYear(from); int month = getMonth(from); int day = getDay(from); to.clear(); to.set(year, month, day); }
From source file:com.taobao.itest.util.DateConverter.java
public static Date mkDate(int year, int month, int date) { Calendar ca = Calendar.getInstance(); ca.set(year, month - 1, date); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); sdf.format(ca.getTime());/* www.ja va 2 s . c o m*/ return ca.getTime(); }
From source file:Main.java
/** * Copy <i>only</i> date information to a new calendar. * * @param from calendar to copy from/*w w w . j av a2 s . c om*/ * @param to calendar to copy to */ public static void copyDateTo(Calendar from, Calendar to) { int year = getYear(from); int month = getMonth(from); int day = getDay(from); to.clear(); to.set(year, month, day); to.getTimeInMillis(); }
From source file:com.haw3d.jadvalKalemat.net.AbstractDownloader.java
protected static Calendar createDate(int year, int month, int day) { Calendar date = Calendar.getInstance(); date.clear();/*from ww w .ja v a2s.c om*/ date.set(year, month - 1, day); // Months start at 0 for Calendar! return date; }
From source file:Main.java
/** * set to the last day of month//w w w . j a v a2 s .c o m * @param calendar */ public static void setToLastDay(Calendar calendar) { int year = getYear(calendar); int month = getMonth(calendar); int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.clear(); calendar.set(year, month, maxDay); calendar.getTimeInMillis(); }
From source file:GanttChart.Gantt.java
/** * Utility method for creating <code>Date</code> objects. * * @param day the date./*from w w w . j a va 2s .c o m*/ * @param month the month. * @param year the year. * * @return a date. */ private static Date date(final int day, final int month, final int year) { final Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day); final Date result = calendar.getTime(); return result; }
From source file:Main.java
/** accurate to day */ public static Calendar getToday() { Calendar cal = Calendar.getInstance(); int year = getYear(cal); int month = getMonth(cal); int day = getDay(cal); cal.clear();//from w w w.jav a 2s .co m cal.set(year, month, day); cal.getTimeInMillis(); return cal; }
From source file:br.com.dgimenes.jsonlibscomparison.JSONLibsTest.java
private static Sales createSales() { Calendar cal = Calendar.getInstance(); List<Sale> saleList = new ArrayList<Sale>(); cal.set(2014, 03, 15); saleList.add(new Sale(1, "Prepare for SCJP! Super discount on Java book 'SCJP Sun Certified Programmer for Java 6 Exam 310-065'", "SCJP Sun Certified Programmer for Java 6 Exam 310-065", new BigDecimal(25.20D), cal.getTime())); cal.set(2014, 03, 05);/* w ww. j av a 2 s . com*/ saleList.add(new Sale(2, "Be a better programmer! 'The Clean Coder' book for half the price!", "The Clean Coder: A Code of Conduct for Professional Programmers", new BigDecimal(15.50D), cal.getTime())); cal.set(2014, 03, 30); saleList.add(new Sale(3, "Now you can learn Test Driven Development! 'Test Driven Development: By Example' book with 25% off!", "Test Driven Development: By Example", new BigDecimal(30.00D), cal.getTime())); return new Sales(saleList); }