List of usage examples for java.util Calendar set
public void set(int field, int value)
From source file:com.wanikani.wklib.UserInformation.java
private static Calendar getNormalizedCalendar(Date date) { Calendar ans; ans = Calendar.getInstance(); ans.setTime(date);//from w ww.j av a 2 s .c o m ans.set(Calendar.HOUR, 1); ans.set(Calendar.MINUTE, 2); ans.set(Calendar.SECOND, 3); ans.set(Calendar.MILLISECOND, 4); return ans; }
From source file:lineage2.gameserver.network.telnet.commands.TelnetStatus.java
/** * Method getGameTime./*from w ww. ja v a2 s . c o m*/ * @return String */ public static String getGameTime() { int t = GameTimeController.getInstance().getGameTime(); int h = t / 60; int m = t % 60; SimpleDateFormat format = new SimpleDateFormat("HH:mm"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, h); cal.set(Calendar.MINUTE, m); return format.format(cal.getTime()); }
From source file:Main.java
/** * Sets the specified field to a date returning a new object. * This does not use a lenient calendar. * The original date object is unchanged. * * @param date the date, not null//from w ww. j a v a 2 s . c om * @param calendarField the calendar field to set the amount to * @param amount the amount to set * @return a new Date object set with the specified value * @throws IllegalArgumentException if the date is null * @since 2.4 */ private static Date set(Date date, int calendarField, int amount) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } // getInstance() returns a new object, so this method is thread safe. Calendar c = Calendar.getInstance(); c.setLenient(false); c.setTime(date); c.set(calendarField, amount); return c.getTime(); }
From source file:com.linuxbox.enkive.teststats.StatsHourGrainTest.java
@SuppressWarnings("unchecked") @BeforeClass/*from ww w . j a va 2 s . co m*/ public static void setUp() throws ParseException, GathererException { gatherTester = TestHelper.BuildGathererService(); coll = TestHelper.GetTestCollection(); client = TestHelper.BuildClient(); grain = new HourConsolidator(client); Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); for (int i = 0; i < 10; i++) { List<RawStats> stats = gatherTester.gatherStats(); List<Map<String, Object>> statsToStore = createListOfMaps(); if (i == 5) { cal.add(Calendar.HOUR, -1); } for (RawStats data : stats) { Map<String, Object> temp = data.toMap(); Map<String, Object> date = (Map<String, Object>) temp.get(STAT_TIMESTAMP); date.put(CONSOLIDATION_MIN, cal.getTime()); date.put(CONSOLIDATION_MAX, cal.getTime()); date.put(STAT_TS_POINT, cal.getTime()); statsToStore.add(temp); } client.storeData(statsToStore); } dataCount = coll.count(); }
From source file:ru.retbansk.utils.marshaller.Jaxb2MarshallerTest.java
@BeforeClass public static void beforeClass() { TaskReport taskReport = new TaskReport(); Date date = new Date(); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT")); calendar.clear();//from w w w . j a v a 2s .c o m calendar.set(Calendar.DATE, 1); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.YEAR, 1981); date = calendar.getTime(); taskReport.setDate(date); taskReport.setElapsedTime(4); taskReport.setStatus(STATUS); taskReport.setWorkDescription(WORK_DESCRIPTION); list = new ArrayList<TaskReport>(); list.add(taskReport); }
From source file:com.ekom.ekomerp.global.DateTimeUtils.java
public static Date getFirstDayOfMonth(Date date) { Calendar calendar = getCalendarWithoutTime(date); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.getTime(); }
From source file:com.ekom.ekomerp.global.DateTimeUtils.java
public static Date getLastDayOfMonth(Date date) { Calendar calendar = getCalendarWithoutTime(date); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); return calendar.getTime(); }
From source file:com.tinypace.mobistore.util.DateUtils.java
/** * ? /*from w w w . j a v a 2s . c o m*/ * * @param d * @param day * @return */ public static Date getDateBefore(Date d, int day) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.set(Calendar.DATE, cal.get(Calendar.DATE) - day); return cal.getTime(); }
From source file:com.tinypace.mobistore.util.DateUtils.java
/** * ? /*from w ww . j a v a 2s . c om*/ * * @param d * @param day * @return */ public static Date getDateAfter(Date d, int day) { Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.set(Calendar.DATE, cal.get(Calendar.DATE) + day); return cal.getTime(); }
From source file:emily.util.YTUtil.java
/** * Time until the next google api reset happens (Midnight PT), or 9am GMT * * @return formatted string, eg. "10 minutes form now" *///from w w w . j a v a2 s .com public static String nextApiResetTime() { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_MONTH, 0); c.set(Calendar.HOUR_OF_DAY, 9); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return TimeUtil.getRelativeTime( (System.currentTimeMillis() + (c.getTimeInMillis() - System.currentTimeMillis()) % TimeUnit.DAYS.toMillis(1)) / 1000L, false); }