Java Code Examples for java.text.ParseException.printStackTrace()

The following are Jave code examples for showing how to use printStackTrace() of the java.text.ParseException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: schulcloud-mobile-android   File: DashboardFragment.java   View Source Code Vote up 6 votes
/***** MVP View methods implementation *****/
@Override
public void showOpenHomework(@NonNull Pair<String, String> openHomework) {
    Date date = null;
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
    SimpleDateFormat simpleDateFormatDeux = new SimpleDateFormat("yyyy-MM-dd  HH:mm");
    try {
        date = simpleDateFormat.parse(openHomework.getSecond());
    } catch (ParseException e) {
        e.printStackTrace();
    }
    openTasks.setText(openHomework.getFirst());
    if (openHomework.getSecond().equals("10000-01-31T23:59"))
        dueTillDate.setText("...");
    else
        dueTillDate.setText(simpleDateFormatDeux.format(date));
    cardViewHomework.setOnClickListener(v -> addFragment(HomeworkFragment.newInstance()));
}
 
Example 2
Project: TeamNote   File: ConvertUtilImpl.java   View Source Code Vote up 6 votes
public String formMessage(String content) {
    try {
        JsonObject contentObj = new JsonParser().parse(content).getAsJsonObject();
        int userId = contentObj.get("uid").getAsInt();
        String datetime = contentObj.get("datetime").getAsString();
        SimpleDateFormat insdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
        SimpleDateFormat outsdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String parsedDatetime = outsdf.format(insdf.parse(datetime));
        String chatContent = contentObj.get("content").getAsString();
        String username = userDao.getUserById(userId).getUsername();
        String avatar = userDao.getUserById(userId).getAvatar();

        JsonObject messageJson = new JsonObject();
        messageJson.addProperty("uid", userId);
        messageJson.addProperty("username", username);
        messageJson.addProperty("datetime", parsedDatetime);
        messageJson.addProperty("avatar", avatar);
        messageJson.addProperty("content", chatContent);
        return messageJson.toString();
    } catch (ParseException e) {
        e.printStackTrace();
        return "error";
    }
}
 
Example 3
Project: Huochexing12306   File: TimeUtil.java   View Source Code Vote up 6 votes
/**
 * 返回格式化的日期时间字串
 * 
 * @param strDateTime0
 *            日期时间,"yyyy-MM-dd HH:mm"
 * @param strTime1
 *            时间,"HH:mm"
 * @return strDateTime0+strTime1返回"yyyy-MM-dd HH:mm"格式字符串
 */
public static String getFmt_DT_T_SumStr(String strDateTime0, String strTime1) {
	SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm",
			Locale.getDefault());
	Date date1 = null;
	try {
		date1 = df1.parse(strDateTime0);
	} catch (ParseException e1) {
		e1.printStackTrace();
	}
	Calendar c = Calendar.getInstance(Locale.getDefault());
	c.setTime(date1);
	String[] strTimes2 = strTime1.split(":");
	c.add(Calendar.HOUR_OF_DAY, Integer.valueOf(strTimes2[0]));
	c.add(Calendar.MINUTE, Integer.valueOf(strTimes2[1]));
	SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm",
			Locale.getDefault());
	return df2.format(c.getTime());
}
 
Example 4
Project: backend.ai-client-java   File: AuthTest.java   View Source Code Vote up 6 votes
@Test
public void getCredentialString() {
    ClientConfig config = new ClientConfig.Builder().accessKey("TESTESTSERSERESTSET").secretKey("KJSAKDFJASKFDJASDFJSAFDJSJFSAJFSDF").build();

    Auth auth = new Auth(config);
    String body = "";

    SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    ISO8601DATEFORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
    String date_s = "2017-10-28T19:57:56";
    Date date = new Date();
    try {
        date = ISO8601DATEFORMAT.parse(date_s);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    String a = auth.getCredentialString("POST", "/v2/kernel/create", date, body);
    assertEquals(a, "TESTESTSERSERESTSET:dcd926f4b281e05d384b3debccd540b1cd9ad30c184f5797057616f3b86b2cc3");

}
 
Example 5
Project: Android-PickerDialog   File: BaseDatePickerDialog.java   View Source Code Vote up 5 votes
public void clickSubmit(View v) {
    if (mTimeSelectListener != null) {
        try {
            Date date = WheelTime.dateFormat.parse(mWheelTime.getTime());
            mTimeSelectListener.onTimeSelect(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    dismiss();
}
 
Example 6
Project: TripBuyer   File: DateUtil.java   View Source Code Vote up 5 votes
public static Date s2d(String dateStr) {
    Date date = new Date();
    try {
        date = new SimpleDateFormat(LEAN_FORMAT, Locale.CHINA).parse(dateStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return date;
}
 
Example 7
Project: AndroidSkinAnimator   File: TimeUtil.java   View Source Code Vote up 5 votes
public static Long farmatTime(String string) {
    Date date = null;
    try {
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        date = Date(sf.parse(string));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date.getTime();
}
 
Example 8
Project: My-Blog   File: DateKit.java   View Source Code Vote up 5 votes
public static int getBetweenTodaysStartDateAndEndDate(Date startDate, Date endDate) {
    byte betweentoday = 0;
    if(startDate == null) {
        return betweentoday;
    } else {
        if(endDate == null) {
            Calendar calendar = Calendar.getInstance();
            String year = Integer.toString(calendar.get(Calendar.YEAR));
            String month = Integer.toString(calendar.get(Calendar.MONTH) + 1);
            String day = Integer.toString(calendar.get(Calendar.DATE));
            String strtodaytime = year + "-" + month + "-" + day;
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

            try {
                endDate = formatter.parse(strtodaytime);
            } catch (ParseException var10) {
                var10.printStackTrace();
            }
        }

        int betweentoday1;
        if(endDate.after(startDate)) {
            betweentoday1 = (int)((endDate.getTime() - startDate.getTime()) / 86400000L);
        } else {
            betweentoday1 = (int)((startDate.getTime() - endDate.getTime()) / 86400000L);
        }

        return betweentoday1;
    }
}
 
Example 9
Project: wcs-android-sdk   File: DateUtil.java   View Source Code Vote up 5 votes
public static Date parseDate(String time, String pattern, Locale local) {
    SimpleDateFormat format = new SimpleDateFormat(pattern, local);
    try {
        return format.parse(time);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 10
Project: DeviceInfo   File: Methods.java   View Source Code Vote up 5 votes
/**
 * Change format of date.
 *
 * @param dateTime:   notification date which is converted to local from GMT.
 * @param newFormate: Need to convert format.
 * @return: date with format.
 */
private static String getDateFormate(String dateTime, String newFormate) {
    DateFormat inputFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    DateFormat outputFormate = new SimpleDateFormat(newFormate + " 'at' " + "hh:mm aa");
    try {
        Date date = inputFormate.parse(dateTime);
        String outputDateWithFormate = outputFormate.format(date);
        return outputDateWithFormate;
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return "";
}
 
Example 11
Project: DoList   File: Festival.java   View Source Code Vote up 5 votes
public long changedatetime(String dateStr) {
	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
	Date date;

	try {
		date = format.parse(dateStr);
		return date.getTime();
	} catch (ParseException e) {
		e.printStackTrace();
	}
	return 0;
}
 
Example 12
Project: couch-potatoes   File: MessageActivity.java   View Source Code Vote up 5 votes
/**
 * Returns the time in AM PM format
 * @param time to convert
 * @return the time in AM PM format
 */
private String toAmPm(String time) {
    String hourStr = "";
    DateFormat readFormat = new SimpleDateFormat("HH:mm:ss");
    DateFormat writeFormat = new SimpleDateFormat("hh:mm a");
    try {
        hourStr = writeFormat.format(readFormat.parse(time));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return hourStr;
}
 
Example 13
Project: Android-Gank-Share   File: TimeUtil.java   View Source Code Vote up 5 votes
public static Date getDayBefore(Date date, int days){
    calendar.setTime(date);
    calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - days);
    try {
        date = format.parse(format.format(calendar.getTime()));
    }catch (ParseException e){
        e.printStackTrace();
    }
    return date;
}
 
Example 14
Project: ChronoBike   File: DateUtil.java   View Source Code Vote up 5 votes
/**
 * Initialise la date
 */
public void setDate(String cs) 
{
	DateFormat df = DateFormat.getInstance() ;
	Date date ;
	try
	{
		date = df.parse(cs);
		calendar.setTime(date);
	} 
	catch (ParseException e)
	{
		e.printStackTrace();
	}
}
 
Example 15
Project: GongXianSheng   File: TimeUtils.java   View Source Code Vote up 5 votes
public static String getHM(String date) {
	SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	SimpleDateFormat ft1 = new SimpleDateFormat("HH:mm");
	Date date1 = null;
	try {
		date1 = ft.parse(date);
	} catch (ParseException e) {
		e.printStackTrace();
		return "";
	}

	return ft1.format(date1);
}
 
Example 16
Project: HiTSDB-Client   File: TestHiTSDBClientPut.java   View Source Code Vote up 5 votes
private static int getTime() {
    int time;
    try {
        String strDate = "2017-08-17 13:14:15";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        time = (int) (sdf.parse(strDate).getTime() / 1000);
    } catch (ParseException e) {
        e.printStackTrace();
        time = 0;
    }
    return time;

}
 
Example 17
Project: Swap   File: DateUtil.java   View Source Code Vote up 5 votes
/**
 * 格式化时间
 * @param format
 * @return
 */
public String getFormatTime(String time, DateFormat format){

    SimpleDateFormat sdf = new SimpleDateFormat(format.getValue());// 格式化对象

    Date date = null;
    try {
        date = sdf.parse(time);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date!=null?sdf.format(date):time;
}
 
Example 18
Project: amap   File: MIP_DateUtil.java   View Source Code Vote up 4 votes
private static String getPreWeekDay(String dateStr)
{
    
    getPreWeekDay(dateStr);
    Date date = null;
    try
    {
        date = yyyyMMdd.parse(dateStr);
    }
    catch (ParseException e)
    {
        e.printStackTrace();
    }
    return "";
}
 
Example 19
Project: Tribe   File: LifeAdapter.java   View Source Code Vote up 4 votes
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    LifeBean lifeBean = mData.get(position);
    String total = lifeBean.getName();
    String[] split = total.split(",");
    String titleName = split[0];
    String userPic = ApiService.BASEURLPIC + lifeBean.getPics();
    String detailPic = ApiService.BASEURLPIC + lifeBean.getDetail_pics();
    String endTime = lifeBean.getTime();
    String createTime = lifeBean.getCreate_time();
    String address = lifeBean.getAddress();

    holder.userName.setText(titleName);
    holder.location.setText(address);
    holder.time.setText(createTime);
    OvLoad ovLoad = new OvLoad();
    ovLoad.loadPicture(mActivity,userPic,holder.customImageView);
    ovLoad.loadPicture(mActivity,detailPic,holder.detailView);

    long currentTime = System.currentTimeMillis();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    if(endTime != null){
        try {
            Date date = simpleDateFormat.parse(endTime);
            long endLong = date.getTime();

            if(endLong > currentTime){//活动还没结束
                holder.showRecruit.setVisibility(View.VISIBLE);
                holder.showFinish.setVisibility(View.GONE);
            }else {
                holder.showFinish.setVisibility(View.VISIBLE);
                holder.showRecruit.setVisibility(View.GONE);
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }




}
 
Example 20
Project: Huochexing12306   File: AddInfoAty.java   View Source Code Vote up 4 votes
private void initViews() {
	btnFrom = (Button) findViewById(R.id.from);
	btnFrom.setOnClickListener(this);
	btnTo = (Button) findViewById(R.id.to);
	btnTo.setOnClickListener(this);
	btnTrainNum = (Button) findViewById(R.id.trainNum); // 车次
	btnTrainNum.setOnClickListener(this);
	etDate = (EditText)findViewById(R.id.date);
	btnDate = (Button) findViewById(R.id.btnDate); // 选择乘车日期
	btnDate.setOnClickListener(this);
	btnOK = (Button) findViewById(R.id.ok);
	btnOK.setOnClickListener(this);
	etTravelName = (EditText) findViewById(R.id.travelName);
	etTime = (EditText) findViewById(R.id.time);
	
	btnFrom.setText(setSP.getLastFromStationKey());
	btnTo.setText(setSP.getLastToStationKey());
	// 取得当前日期
	Calendar c = Calendar.getInstance(Locale.getDefault());
	c.setTimeInMillis(System.currentTimeMillis());
	intYear = c.get(Calendar.YEAR);
	intMonth = c.get(Calendar.MONTH);
	intDay = c.get(Calendar.DAY_OF_MONTH);
	String strDate = TimeUtil.getDFormat().format(c.getTime());
	etDate.setText(strDate + "  " + TimeUtil.getWeek(c.getTime()));
	etDate.setTag(strDate);
	
	if (this.getIntent().getStringExtra(TRAIN_NUM) != null){
		strTrainNum = this.getIntent().getStringExtra(TRAIN_NUM);
		btnFrom.setText(this.getIntent().getStringExtra(START_STATION));
		btnTo.setText(this.getIntent().getStringExtra(END_STATION));
		intDataSource = this.getIntent().getIntExtra(DATA_SOURCE, DATA_FROM_OFFINE_DB);
		
		if (intDataSource == DATA_FROM_OFFINE_DB){
			SimpleDialogFragment
			.createBuilder(
					AddInfoAty.this,
					getSupportFragmentManager())
			.setCancelable(false)
			.setRequestCode(REQUET_SET_TRAVEL_BRIEF_OF_DATA_FROM_OFFLINE_DB)
			.setTitle("提示")
			.setMessage("检测到您采用离线数据快速添加数据,为保证数据准确性请您手动进行车次选择"+SF.TIP)
			.setPositiveButtonText("确定")
			.show();
		}
		String strStartTime = getIntent().getStringExtra(EXTRA_START_TIME);
		if (!TextUtils.isEmpty(strStartTime)){
			try {
				Date date1 = TimeUtil.getDFormat().parse(strStartTime);
				strStartTime = TimeUtil.getDFormat().format(date1);
				etDate.setText(strStartTime + " " + TimeUtil.getWeek(strStartTime));
				etDate.setTag(strStartTime);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		getTrains();
	}
}