当前位置: 首页>>代码示例>>Java>>正文


Java Date.setMonth方法代码示例

本文整理汇总了Java中java.util.Date.setMonth方法的典型用法代码示例。如果您正苦于以下问题:Java Date.setMonth方法的具体用法?Java Date.setMonth怎么用?Java Date.setMonth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Date的用法示例。


在下文中一共展示了Date.setMonth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBindViewHolder

import java.util.Date; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Weather weather = weatherList.get(position);
    String[] time = weather.dayName.split(" ");
    String[] weatherTime = time[1].split(":");
    String[] date = time[0].split("-");
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
    Date d = new Date();
    d.setYear(Integer.parseInt(date[0]));
    d.setMonth(Integer.parseInt(date[1]) - 1);
    d.setDate(Integer.parseInt(date[2]) - 1);
    String dayOfTheWeek = sdf.format(d);
    Log.d("DAY", weather.dayName + " : " + dayOfTheWeek);
    holder.dayName.setText(NumbersLocal.convertNumberType(context, weatherTime[0] + ":" + weatherTime[1] + ""));
    holder.weather.setText(NumbersLocal.convertNumberType(context, weather.tempMini + "°"));
    holder.image.setImageResource(WeatherIcon.get_icon_id_white(weather.image));
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:18,代码来源:WeatherAdapter.java

示例2: showDate

import java.util.Date; //导入方法依赖的package包/类
/**
 * Function to show saved weather
 *
 * @param weathers Saved weathers
 * @param position Position
 * @param temp     Temp text view
 * @param image    Weather view
 * @param day      Day of week text view
 */
public void showDate(List<mindtrack.muslimorganizer.model.Weather> weathers, int position
        , TextView temp, ImageView image, TextView day) {
    try {
        mindtrack.muslimorganizer.model.Weather weather = weathers.get(position);
        String[] time = weather.dayName.split(" ");
        String[] date = time[0].split("-");
        SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
        Date d = new Date();
        d.setYear(Integer.parseInt(date[0]));
        d.setMonth(Integer.parseInt(date[1]) - 1);
        d.setDate(Integer.parseInt(date[2]) - 1);
        String dayOfTheWeek = sdf.format(d);
        day.setText(dayOfTheWeek);
        image.setImageResource(WeatherIcon.get_icon_id_white(weather.image));
        temp.setText(NumbersLocal.convertNumberType(getContext(), "°" + weather.tempMax + " | " + weather.tempMini + "°"));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:29,代码来源:WeatherFragment.java

示例3: generateRandomDateTime

import java.util.Date; //导入方法依赖的package包/类
public Date generateRandomDateTime(){
    Date date = new Date();
    int year = randBetween(year_min-1900, year_max-1900);
    int month = randBetween(month_min, month_max);
    int day = randBetween(day_min, day_max);
    int hour = randBetween(hour_min, hour_max);
    int minute = randBetween(minute_min, minute_max);
    int second = randBetween(second_min, second_max);
    
    date.setYear(year);
    date.setMonth(month);
    date.setDate(day);
    date.setHours(hour);
    date.setMinutes(minute);
    date.setSeconds(second);
   
    return date;
}
 
开发者ID:faclc4,项目名称:HTAPBench,代码行数:19,代码来源:RandomParameters.java

示例4: Date

import java.util.Date; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@ActionLayout(named = "Dias restantes para el cumpleaños", cssClassFa = "fa-birthday-cake")
public long calcularDiasRestantesParaCumpleaños() {
	Calendar hoyCal = Calendar.getInstance();
	Date hoyDate = hoyCal.getTime();
	Date cumpleaños = new Date();
	long cant;
	cumpleaños.setDate(this.getClienteFechaNacimiento().getDate());
	cumpleaños.setMonth(this.getClienteFechaNacimiento().getMonth());
	cumpleaños.setYear(hoyDate.getYear());
	if (cumpleaños.before(hoyDate)) {
		cumpleaños.setYear(cumpleaños.getYear() + 1);
	}
	cant = getDifferenceDays(hoyDate, cumpleaños);
	return cant;
}
 
开发者ID:leandrogonqn,项目名称:Proyecto2017Seguros,代码行数:17,代码来源:Cliente.java

示例5: ok_actionPerformed

import java.util.Date; //导入方法依赖的package包/类
private void ok_actionPerformed(ActionEvent e) {
	Date d = (Date)date.getValue();
	Date start = (Date)timeStart.getValue();
	Date stop = (Date)timeStop.getValue();
	start.setYear(d.getYear());
	start.setMonth(d.getMonth());
	start.setDate(d.getDate());
	stop.setYear(d.getYear());
	stop.setMonth(d.getMonth());
	stop.setDate(d.getDate());
	timeStart.setValue(start);
	timeStop.setValue(stop);
	this.dispose();
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:15,代码来源:TimeLogDialog.java

示例6: isDateOdd

import java.util.Date; //导入方法依赖的package包/类
public static boolean isDateOdd(String date) {
        Date dt1 = new Date(date);
        Date dt2 = new Date(date);
        dt1.setMonth(0);
        dt1.setDate(1);

//        System.out.println(dt1.getTime());
//        System.out.println(dt2.getTime());
        long a = (dt2.getTime()-dt1.getTime())/(3600*24*1000)+1;
        if (a % 2 != 0)
            return true;
        //System.out.println(dt2.getTime()-dt1.getTime());
        //System.out.println (a);
        return false;
    }
 
开发者ID:avedensky,项目名称:JavaRushTasks,代码行数:16,代码来源:Solution.java

示例7: getCookieExpireDate

import java.util.Date; //导入方法依赖的package包/类
/**
 * Get Cookie Date
 * @return Now Date
 */
public static Date getCookieExpireDate() {
	Date now = new Date();
	now.setMonth(now.getMonth() + 1);
	;

	return now;
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:12,代码来源:Util.java


注:本文中的java.util.Date.setMonth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。