本文整理汇总了Java中com.ibm.icu.util.Calendar.getTime方法的典型用法代码示例。如果您正苦于以下问题:Java Calendar.getTime方法的具体用法?Java Calendar.getTime怎么用?Java Calendar.getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.util.Calendar
的用法示例。
在下文中一共展示了Calendar.getTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeDefaultCenturyStart
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
private void initializeDefaultCenturyStart(long baseTime) {
defaultCenturyBase = baseTime;
// clone to avoid messing up date stored in calendar object
// when this method is called while parsing
Calendar tmpCal = (Calendar)calendar.clone();
tmpCal.setTimeInMillis(baseTime);
tmpCal.add(Calendar.YEAR, -80);
defaultCenturyStart = tmpCal.getTime();
defaultCenturyStartYear = tmpCal.get(Calendar.YEAR);
}
示例2: getEarliestDate
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Date getEarliestDate() {
Calendar cal = getCalendarInstance(TimeZone.getTimeZone("GMT"), Locale.getDefault());
cal.set(Calendar.YEAR, cal.getActualMinimum(Calendar.YEAR));
cal.set(Calendar.MONTH, cal.getActualMinimum(Calendar.MONTH));
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
示例3: getLatestDate
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static Date getLatestDate() {
Calendar cal = getCalendarInstance(TimeZone.getTimeZone("GMT"), Locale.getDefault());
cal.set(Calendar.YEAR, cal.getActualMaximum(Calendar.YEAR));
cal.set(Calendar.MONTH, cal.getActualMaximum(Calendar.MONTH));
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
return cal.getTime();
}
示例4: getRange
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
/** Returns a range of dates matching this expression. Returns an
* empty Set if no dates are found.
* @param range The range of dates to evaluate
* @param cal The starting date
* @return A Set of matching <code>Date</code> objects
*/
public Set<Date> getRange(org.ofbiz.base.util.DateRange range, Calendar cal) {
Set<Date> set = new TreeSet<Date>();
Date last = range.start();
Calendar next = first(cal);
while (next != null && range.includesDate(next.getTime())) {
last = next.getTime();
set.add(last);
next = next(next);
if (next != null && last.equals(next.getTime())) {
break;
}
}
return set;
}
示例5: convert
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public Date convert(Calendar obj) throws ConversionException {
return obj.getTime();
}
示例6: getTimeUntilAlarmDisplayString
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
public static String getTimeUntilAlarmDisplayString(Context context, long timeUntilAlarm) {
Calendar calendarNow = Calendar.getInstance();
Calendar calendarAlarm = Calendar.getInstance();
calendarAlarm.setTimeInMillis(timeUntilAlarm);
Date alarmTime = calendarAlarm.getTime();
// It's very important we make the fieldDifference calls in this order. Each time
// calendarNow moves closer to alarmTime by the difference units it returns. This implies
// that you start with the largest calendar unit and move to smaller ones if you want
// accurate results for different units between the two times.
int days = Math.max(0, calendarNow.fieldDifference(alarmTime, Calendar.DATE));
int hours = Math.max(0, calendarNow.fieldDifference(alarmTime, Calendar.HOUR_OF_DAY));
int minutes = Math.max(0, calendarNow.fieldDifference(alarmTime, Calendar.MINUTE));
Map<String,Integer> args = new HashMap<>();
try {
args.put("days", days);
args.put("hours", hours);
args.put("minutes", minutes);
} catch (Exception e) {
Logger.trackException(e);
}
int resourceIdForDisplayString;
if (days > 0) {
if (hours > 0 && minutes > 0) {
resourceIdForDisplayString = R.string.alarm_set_day_hour_minute;
} else if (hours > 0) {
resourceIdForDisplayString = R.string.alarm_set_day_hour;
} else if (minutes > 0) {
resourceIdForDisplayString = R.string.alarm_set_day_minute;
} else {
resourceIdForDisplayString = R.string.alarm_set_day;
}
} else if (hours > 0) {
if (minutes > 0) {
resourceIdForDisplayString = R.string.alarm_set_hour_minute;
} else {
resourceIdForDisplayString = R.string.alarm_set_hour;
}
} else if (minutes > 0) {
resourceIdForDisplayString = R.string.alarm_set_minute;
} else {
resourceIdForDisplayString = R.string.alarm_set_less_than_minute;
}
return new MessageFormat(context.getString(resourceIdForDisplayString)).format(args);
}
示例7: testEquals
import com.ibm.icu.util.Calendar; //导入方法依赖的package包/类
@Test
public void testEquals() throws Exception {
final Date dateCreated = new Date();
final String usenetMessageID = "ID1";
final String subject = "Bad day";
final UsenetUser poster = new UsenetUser("Steve", "[email protected]", "127.0.0.1", "male",
new Location("city", "Country", "CountryCode", false, new ArrayList<>(),
new ArrayList<>()));
final Set<NewsGroup> newsgroups = new HashSet<>();
final Set<Topic> topics = new HashSet<>();
final Set<Message> messages = new HashSet<>();
newsgroups.add(new NewsGroup("alt.rubbish", null, topics, messages, 2, 2, 1, 2,
"alt.rubbish", true));
final Topic topic = new Topic("rubbish", newsgroups);
topics.add(topic);
final String referencedMessages = null;
final byte[] messageBody = "This is bad".getBytes();
final Message thisOne = new Message(dateCreated, usenetMessageID, subject, poster, topic,
newsgroups, referencedMessages, messageBody);
final Message sameOne = new Message(dateCreated, usenetMessageID, subject, poster, topic,
newsgroups, referencedMessages, messageBody);
Assert.assertEquals(thisOne, sameOne);
Assert.assertEquals(thisOne, thisOne);
Assert.assertTrue(thisOne.equals(sameOne));
final Calendar instance = Calendar.getInstance();
instance.add(Calendar.YEAR, 1);
final Message thatone = new Message(instance.getTime(), usenetMessageID, subject, poster,
topic, newsgroups, referencedMessages, messageBody);
Assert.assertFalse(thisOne + ":" + thatone, thisOne.equals(thatone));
Assert.assertFalse(thisOne.equals(new Message(dateCreated, usenetMessageID + "2", subject,
poster, topic, newsgroups, referencedMessages, messageBody)));
Assert.assertFalse(thisOne.equals(new Message(dateCreated, usenetMessageID, subject + "2",
poster, topic, newsgroups, referencedMessages, messageBody)));
Assert.assertFalse(thisOne.equals(new Message(dateCreated, usenetMessageID, subject,
new UsenetUser(poster).setGender("female"), topic, newsgroups, referencedMessages,
messageBody)));
Assert.assertFalse(thisOne.equals(new Message(dateCreated, usenetMessageID, subject, poster,
new Topic(topic).setSubject("new subject"), newsgroups, referencedMessages,
messageBody)));
Assert.assertFalse(thisOne.equals(new Message(dateCreated, usenetMessageID, subject, poster,
topic, newsgroups, "[email protected]", messageBody)));
Assert.assertFalse(thisOne.equals(new Message(dateCreated, usenetMessageID, subject, poster,
topic, newsgroups, referencedMessages, "another".getBytes())));
final Set<NewsGroup> newsgroups2 = new HashSet<>(newsgroups);
newsgroups2.add(Mockito.mock(NewsGroup.class));
Assert.assertFalse(thisOne.equals(new Message(dateCreated, usenetMessageID, subject, poster,
topic, newsgroups2, referencedMessages, messageBody)));
Assert.assertFalse(thisOne.equals(null));
Assert.assertFalse(thisOne.equals("eggs"));
}