本文整理了Java中java.util.Date.getMinutes()
方法的一些代码示例,展示了Date.getMinutes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.getMinutes()
方法的具体详情如下:
包路径:java.util.Date
类名称:Date
方法名:getMinutes
[英]Returns the gregorian calendar minute of the hour for this Date object.
[中]返回此日期对象的公历小时分钟数。
代码示例来源:origin: alibaba/jstorm
public static String toTimeStr(Date time) {
int hour = time.getHours();
int min = time.getMinutes();
StringBuilder sb = new StringBuilder();
if (hour < 10) {
sb.append(0).append(hour);
} else {
sb.append(hour);
}
sb.append(":");
if (min < 10) {
sb.append(0).append(min);
} else {
sb.append(min);
}
return sb.toString();
}
代码示例来源:origin: prestodb/presto
/**
* 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
);
}
代码示例来源:origin: stackoverflow.com
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);
代码示例来源:origin: prestodb/presto
date.getHours(),
date.getMinutes(),
date.getSeconds(),
(((int) (date.getTime() % 1000)) + 1000) % 1000
);
代码示例来源:origin: stackoverflow.com
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
Date date = cal.getTime();
mHour = date.getHours();
mMinute = date.getMinutes();
代码示例来源:origin: com.jtransc/jtransc-rt
@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()));
}
代码示例来源:origin: joda-time/joda-time
/**
* 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
);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @throws HL7Exception
* @see HL7Util#parseHL7Time(String)
*/
@Test
@SuppressWarnings("deprecation")
public void parseHL7Time_shouldHandle0615() throws HL7Exception {
// set tz to be a __non DST__ timezone so this junit test works everywhere and always
TimeZone originalTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("EAT"));
Date parsedDate = HL7Util.parseHL7Time("0615");
Assert.assertEquals(6, parsedDate.getHours());
Assert.assertEquals(15, parsedDate.getMinutes());
// reset the timezone
TimeZone.setDefault(originalTimeZone);
}
代码示例来源:origin: joda-time/joda-time
date.getHours(),
date.getMinutes(),
date.getSeconds(),
(((int) (date.getTime() % 1000)) + 1000) % 1000
);
代码示例来源:origin: jobxhub/JobX
public static int ofMinutes(Date date){
int h = date.getHours() * 60;
int m = date.getMinutes();
return h+m;
}
代码示例来源:origin: JodaOrg/joda-time
/**
* 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
);
}
代码示例来源:origin: stackoverflow.com
String time = "13:10";
DateFormat sdf = new SimpleDateFormat("HH:mm"); // or "hh:mm" for 12 hour format
Date date = sdf.parse(time);
date.getHours(); // int
date.getMinutes(); // int
代码示例来源:origin: JodaOrg/joda-time
date.getHours(),
date.getMinutes(),
date.getSeconds(),
(((int) (date.getTime() % 1000)) + 1000) % 1000
);
代码示例来源:origin: stackoverflow.com
try
{
SimpleDateFormat format = new SimpleDateFormat("H:m");
Date date = format.parse("15:34");
int hours = date.getHours();
int min = date.getMinutes();
}
catch (ParseException e)
{
// parsing failed
}
代码示例来源:origin: prestodb/presto
date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
(((int) (date.getTime() % 1000)) + 1000) % 1000
);
代码示例来源:origin: stackoverflow.com
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(System.currentTimeMillis());
Date date = cal.getTime();
mHour = date.getHours();
mMinute = date.getMinutes();
代码示例来源:origin: joda-time/joda-time
date.getMonth() + 1,
date.getDate(),
date.getHours(),
date.getMinutes(),
date.getSeconds(),
(((int) (date.getTime() % 1000)) + 1000) % 1000
);
代码示例来源:origin: stackoverflow.com
SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd hh:mm");
java.util.Date date = null;
try
{
date = form.parse(string);
}
catch (ParseException e)
{
}
SimpleDateFormat postFormater = new SimpleDateFormat("dd-MM-yyyy");
String newDateStr = "at"+date.getHours()+":"+date.getMinutes()+"on"+postFormater.format(date);
代码示例来源:origin: com.alibaba/fastjson
@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);
}
}
代码示例来源:origin: stackoverflow.com
DateFormat dateFormat=new SimpleDateFormat("HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // <-- Add this.
Date hora=dateFormat.parse("00:00:01");
System.out.println(hora.getHours()+" "+hora.getMinutes());
System.out.println("Date "+hora);
System.out.println("Seconds "+TimeUnit.MILLISECONDS.toSeconds(hora.getTime()));
内容来源于网络,如有侵权,请联系作者删除!