本文整理匯總了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());
}