Refine search
/** * Constructs a TimeOfDay from a <code>java.util.Date</code> * using exactly the same field values avoiding any time zone effects. * <p> * Each field is queried from the Date and assigned to the TimeOfDay. * This is useful to ensure that the field values are the same in the * created TimeOfDay no matter what the time zone is. For example, if * the Calendar states that the time is 04:29, then the created TimeOfDay * will always have the time 04:29 irrespective of time zone issues. * <p> * This factory method always creates a TimeOfDay with ISO chronology. * * @param date the Date to extract fields from * @return the created TimeOfDay * @throws IllegalArgumentException if the calendar is null * @throws IllegalArgumentException if the date is invalid for the ISO chronology * @since 1.2 */ public static TimeOfDay fromDateFields(Date date) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } return new TimeOfDay( date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 ); }
java.sql.Time sqlTime = new java.sql.Time(1,0,0); LocalTime localTime = new LocalTime(sqlTime.getHours(), sqlTime.getMinues(), sqlTime.getSeconds());
You can use below code to run TimerTask every hours HH:00:- Timer timer = new Timer(); Calendar cd = Calendar.getInstance(); Date dt = cd.getTime(); long mmss = dt.getMinutes() * 60 + dt.getSeconds(); long remTime = 60 * 60 * 60 - mmss; timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { // TODO Auto-generated method stub } }, remTime * 1000, 60*60 * 60 * 1000);
date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 );
Timer t=new Timer(); t.schedule(new TimerTask() { @Override public void run() { final Date d = new Date(); runOnUiThread(new Runnable() { @Override public void run() { textView.setText(d.getMinutes() +":" + d.getSeconds()); } }); } }, 0,1000);
@Deprecated @JTranscMethodBody(target = "js", value = "this._date.setMinutes(p0);") public void setMinutes(int minutes) { this.setTimestamp(JTranscTime.make(getFullYear(), getMonth(), getDate(), getHours(), minutes, getSeconds(), getMilliseconds())); }
/** * Constructs a TimeOfDay from a <code>java.util.Date</code> * using exactly the same field values avoiding any time zone effects. * <p> * Each field is queried from the Date and assigned to the TimeOfDay. * This is useful to ensure that the field values are the same in the * created TimeOfDay no matter what the time zone is. For example, if * the Calendar states that the time is 04:29, then the created TimeOfDay * will always have the time 04:29 irrespective of time zone issues. * <p> * This factory method always creates a TimeOfDay with ISO chronology. * * @param date the Date to extract fields from * @return the created TimeOfDay * @throws IllegalArgumentException if the calendar is null * @throws IllegalArgumentException if the date is invalid for the ISO chronology * @since 1.2 */ public static TimeOfDay fromDateFields(Date date) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } return new TimeOfDay( date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 ); }
@Deprecated @JTranscMethodBody(target = "js", value = "this._date.setHours(p0);") public void setHours(int hours) { this.setTimestamp(JTranscTime.make(getFullYear(), getMonth(), getDate(), hours, getMinutes(), getSeconds(), getMilliseconds())); }
date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 );
/** * Constructs a TimeOfDay from a <code>java.util.Date</code> * using exactly the same field values avoiding any time zone effects. * <p> * Each field is queried from the Date and assigned to the TimeOfDay. * This is useful to ensure that the field values are the same in the * created TimeOfDay no matter what the time zone is. For example, if * the Calendar states that the time is 04:29, then the created TimeOfDay * will always have the time 04:29 irrespective of time zone issues. * <p> * This factory method always creates a TimeOfDay with ISO chronology. * * @param date the Date to extract fields from * @return the created TimeOfDay * @throws IllegalArgumentException if the calendar is null * @throws IllegalArgumentException if the date is invalid for the ISO chronology * @since 1.2 */ public static TimeOfDay fromDateFields(Date date) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } return new TimeOfDay( date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 ); }
date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 );
date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 );
date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 );
@SuppressWarnings("deprecation") public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException { if (object == null) { serializer.out.writeNull(); return; } Date date = (Date) object; JSONObject json = new JSONObject(); json.put("date", date.getDate()); json.put("day", date.getDay()); json.put("hours", date.getHours()); json.put("minutes", date.getMinutes()); json.put("month", date.getMonth()); json.put("seconds", date.getSeconds()); json.put("time", date.getTime()); json.put("timezoneOffset", date.getTimezoneOffset()); json.put("year", date.getYear()); serializer.write(json); } }
/** * Instantiate an AutoML object and start it running. Progress can be tracked via its job(). * * @param buildSpec * @return */ public static AutoML startAutoML(AutoMLBuildSpec buildSpec) { Date startTime = new Date(); // this is the one and only startTime for this run synchronized (AutoML.class) { // protect against two runs whose startTime is the same second if (lastStartTime != null) { while (lastStartTime.getYear() == startTime.getYear() && lastStartTime.getMonth() == startTime.getMonth() && lastStartTime.getDate() == startTime.getDate() && lastStartTime.getHours() == startTime.getHours() && lastStartTime.getMinutes() == startTime.getMinutes() && lastStartTime.getSeconds() == startTime.getSeconds()) startTime = new Date(); } lastStartTime = startTime; } String keyString = buildSpec.build_control.project_name; AutoML aml = AutoML.makeAutoML(Key.<AutoML>make(keyString), startTime, buildSpec); DKV.put(aml); startAutoML(aml); return aml; }
date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), (((int) (date.getTime() % 1000)) + 1000) % 1000 );
System.out.println("only begin time of events="+begin.getHours() + ":" +begin.getMinutes() + ":" +begin.getSeconds()); System.out.println("only begin time of events="+end.getHours() + ":" +end.getMinutes() + ":" +end.getSeconds()); beg_time = begin.getHours();
date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), nanosOfSecond);
long millis = (int)(date.getTime() % Conversions.MILLISECONDS_PER_SECOND); int nanosOfSecond = (int)(millis * Conversions.NANOSECONDS_PER_MILLISECOND); return LocalTime.of(date.getHours(), date.getMinutes(), date.getSeconds(), nanosOfSecond);
Date dob=null; DateFormat df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); dob=df.parse( "2014-02-10 11:15:00" ); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(dob); XMLGregorianCalendar xmlDate2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH), dob.getHours(),dob.getMinutes(),dob.getSeconds(),DatatypeConstants.FIELD_UNDEFINED, cal.getTimeZone().LONG).normalize(); XMLGregorianCalendar xmlDate3 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH),dob.getHours(),dob.getMinutes(),dob.getSeconds(),DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED); System.out.println(xmlDate2); System.out.println(xmlDate3);