本文整理汇总了Java中java.util.Date.getDate方法的典型用法代码示例。如果您正苦于以下问题:Java Date.getDate方法的具体用法?Java Date.getDate怎么用?Java Date.getDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Date
的用法示例。
在下文中一共展示了Date.getDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTime
import java.util.Date; //导入方法依赖的package包/类
public void setTime(long time) {
Date d = new Date(time);
long dtime;
int year = d.getYear() + 1900;
if (year < 1980) {
dtime = (1 << 21) | (1 << 16);
}
else {
dtime = (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
d.getSeconds() >> 1;
}
modificationDate = (short)(dtime >> 16);
modificationTime = (short)(dtime & 0xFFFF);
}
示例2: get6days
import java.util.Date; //导入方法依赖的package包/类
public static String[] get6days(boolean returnString)
{
Date d=getToday();
String [] days=new String[6];
for (int i=0;i<6;i++)
{
Date t=add(d,i-5);
days[i]=t.getMonth()+1+"."+t.getDate();
}
return days;
}
示例3: getNextMonth
import java.util.Date; //导入方法依赖的package包/类
/**
* 获取当天的下一个月
*/
public static String getNextMonth() {
Date t = new Date();
String nmonth = new String();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
//t=sdf.parse(now);
Date nextmonth = new Date((t.getYear() + (t.getMonth() + 1) / 12),
(t.getMonth() + 1) % 12, t.getDate());
nmonth = sdf.format(nextmonth.getTime());
} catch (Exception e) {
e.printStackTrace();
}
return nmonth;
}
示例4: getView
import java.util.Date; //导入方法依赖的package包/类
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
Date date = getItem(position);
if (convertView == null) {
convertView = layoutInflate.inflate(R.layout.calendar_day_item, parent, false);
}
int day = date.getDate();
((TextView) convertView).setText(String.valueOf(day));
boolean isTheSameMonth = false;
if (date.getMonth() == selectedDate.getMonth()) {
isTheSameMonth = true;
}
if (isTheSameMonth) {
((CalendarDayTextView) convertView).setTextColor(Color.parseColor("#000000"));
} else {
((CalendarDayTextView) convertView).setTextColor(Color.parseColor("#666666"));
}
//判断当前日期是否是已签到的日期
if (daySet.size()>0 && daySet.contains(((TextView) convertView).getText()) && isTheSameMonth) {
((CalendarDayTextView) convertView).isSelected = true;
}
return convertView;
}
示例5: setDate
import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void setDate(Date date) {
int dayOfMonth = date.getDate();
if (monthNameVisible) {
caption.setText(dayOfMonth + " " + calendar.getMonthNames()[date.getMonth()]);
} else {
caption.setText("" + dayOfMonth);
}
if (dayOfMonth == 1) {
addStyleName("firstDay");
} else {
removeStyleName("firstDay");
}
this.date = date;
}
示例6: isToday
import java.util.Date; //导入方法依赖的package包/类
public static boolean isToday(Date date) {
Date now = new Date();
boolean result = true;
result &= date.getYear() == now.getYear();
result &= date.getMonth() == now.getMonth();
result &= date.getDate() == now.getDate();
return result;
}
示例7: feature
import java.util.Date; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public double[] feature(Date date) {
double[] x = new double[types.length];
for (int i = 0; i < types.length; i++)
switch (types[i]) {
case YEAR:
x[i] = 1900 + date.getYear();
break;
case MONTH:
x[i] = date.getMonth();
break;
case DAY_OF_MONTH:
x[i] = date.getDate();
break;
case DAY_OF_WEEK:
x[i] = date.getDay();
break;
case HOURS:
x[i] = date.getHours();
break;
case MINUTES:
x[i] = date.getMinutes();
break;
case SECONDS:
x[i] = date.getSeconds();
break;
default:
throw new IllegalStateException("Unknown date feature type: " + types[i]);
}
return x;
}
示例8: get6days
import java.util.Date; //导入方法依赖的package包/类
public static String[] get6days(boolean returnString)
{
Date d=getToday();
String [] days=new String[6];
for (int i=0;i<6;i++)
{
Date t=add(d,i-2);
days[i]=t.getMonth()+1+"."+t.getDate();
}
return days;
}
示例9: main
import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void main(String args[])
{
GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, 1997);
cal.set(Calendar.DAY_OF_YEAR, 1);
Date d = cal.getTime(); // Should be Jan 1
if (d.getMonth() != 0 || d.getDate() != 1) {
throw new RuntimeException("Date isn't Jan 1");
}
}
示例10: initSimulatorName
import java.util.Date; //导入方法依赖的package包/类
private void initSimulatorName(){
Date d = new Date();
ParameterizedPaySim.simulatorName = "PS_" + (d.getYear() + 1900) + (d.getMonth() + 1) + d.getDate() + d.getHours() + d.getMinutes()
+ d.getSeconds() + "_" + this.seed;
//System.out.println(simulatorName + "\n");
File f = new File(System.getProperty("user.dir") +"//outputs//" + ParameterizedPaySim.simulatorName);
f.mkdir();
}
示例11: javaToDosTime
import java.util.Date; //导入方法依赖的package包/类
public static long javaToDosTime(long time) {
Date d = new Date(time);
int year = d.getYear() + 1900;
if (year < 1980) {
return (1 << 21) | (1 << 16);
}
return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
d.getSeconds() >> 1;
}
示例12: javaToDosTime
import java.util.Date; //导入方法依赖的package包/类
/**
* Converts Java time to DOS time.
*/
@SuppressWarnings("deprecation") // Use of date methods
private static long javaToDosTime(long time) {
Date d = new Date(time);
int year = d.getYear() + 1900;
if (year < 1980) {
return ZipEntry.DOSTIME_BEFORE_1980;
}
return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
d.getSeconds() >> 1;
}
示例13: isToday
import java.util.Date; //导入方法依赖的package包/类
/**
* 测试是否是当天
*
* @param date
* 某一日期
* @return true 今天, false-不是
*/
@SuppressWarnings("deprecation")
public static boolean isToday(Date date) {
Date now = new Date();
boolean result = true;
result &= date.getYear() == now.getYear();
result &= date.getMonth() == now.getMonth();
result &= date.getDate() == now.getDate();
return result;
}
示例14: calculateStartFromMinute
import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private long calculateStartFromMinute(long startFromMinutes, Date from,
Date to, int dayOffset) {
boolean eventStartAtDifferentDay = from.getDate() != to.getDate();
if (eventStartAtDifferentDay) {
long minutesOnPrevDay = (getTargetDateByCurrentPosition(dayOffset)
.getTime() - from.getTime()) / DateConstants.MINUTEINMILLIS;
startFromMinutes = -1 * minutesOnPrevDay;
}
return startFromMinutes;
}
示例15: getToday
import java.util.Date; //导入方法依赖的package包/类
public static Date getToday()
{
Date d=new Date();
return new Date(d.getYear(),d.getMonth(),d.getDate());
}