本文整理匯總了Java中java.text.ParseException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java ParseException.printStackTrace方法的具體用法?Java ParseException.printStackTrace怎麽用?Java ParseException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.text.ParseException
的用法示例。
在下文中一共展示了ParseException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showOpenHomework
import java.text.ParseException; //導入方法依賴的package包/類
/***** 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()));
}
示例2: formMessage
import java.text.ParseException; //導入方法依賴的package包/類
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";
}
}
示例3: getFmt_DT_T_SumStr
import java.text.ParseException; //導入方法依賴的package包/類
/**
* 返回格式化的日期時間字串
*
* @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());
}
示例4: getCredentialString
import java.text.ParseException; //導入方法依賴的package包/類
@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");
}
示例5: clickSubmit
import java.text.ParseException; //導入方法依賴的package包/類
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();
}
示例6: s2d
import java.text.ParseException; //導入方法依賴的package包/類
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;
}
示例7: farmatTime
import java.text.ParseException; //導入方法依賴的package包/類
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();
}
示例8: getBetweenTodaysStartDateAndEndDate
import java.text.ParseException; //導入方法依賴的package包/類
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;
}
}
示例9: parseDate
import java.text.ParseException; //導入方法依賴的package包/類
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;
}
示例10: getDateFormate
import java.text.ParseException; //導入方法依賴的package包/類
/**
* 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 "";
}
示例11: changedatetime
import java.text.ParseException; //導入方法依賴的package包/類
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;
}
示例12: toAmPm
import java.text.ParseException; //導入方法依賴的package包/類
/**
* 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;
}
示例13: getDayBefore
import java.text.ParseException; //導入方法依賴的package包/類
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;
}
示例14: setDate
import java.text.ParseException; //導入方法依賴的package包/類
/**
* 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();
}
}
示例15: getHM
import java.text.ParseException; //導入方法依賴的package包/類
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);
}