parseexception

How to convert UTC Date String and remove the T and Z in Java?

余生颓废 提交于 2020-06-11 06:08:48
问题 Am using Java 1.7. Trying to convert: 2018-05-23T23:18:31.000Z into 2018-05-23 23:18:31 DateUtils class: public class DateUtils { public static String convertToNewFormat(String dateStr) throws ParseException { TimeZone utc = TimeZone.getTimeZone("UTC"); SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); sdf.setTimeZone(utc); Date convertedDate = sdf.parse(dateStr); return convertedDate.toString(); } } When trying to use it: String convertedDate = DateUtils.convertToNewFormat(

How to convert UTC Date String and remove the T and Z in Java?

匆匆过客 提交于 2020-06-11 06:08:09
问题 Am using Java 1.7. Trying to convert: 2018-05-23T23:18:31.000Z into 2018-05-23 23:18:31 DateUtils class: public class DateUtils { public static String convertToNewFormat(String dateStr) throws ParseException { TimeZone utc = TimeZone.getTimeZone("UTC"); SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"); sdf.setTimeZone(utc); Date convertedDate = sdf.parse(dateStr); return convertedDate.toString(); } } When trying to use it: String convertedDate = DateUtils.convertToNewFormat(

Parse a empty string into SimpleDateFormat

 ̄綄美尐妖づ 提交于 2020-01-06 09:54:57
问题 So, so far I have this: static SimpleDateFormat df = new SimpleDateFormat("dd MM yyyy"); jDateChooser8 = new com.toedter.calendar.JDateChooser(); when I parse the right date let's say this one: jDateChooser8.setDate(df.parse("24 07 1987")); it's ok, but when I try to parse "" (empty string) jDateChooser8.setDate(df.parse("")); I get an exeption: first line of error is: java.text.ParseException: Unparseable date: "" all I want to do is set date to "" , how to do it? 回答1: The javadoc for parse

Parse a empty string into SimpleDateFormat

蹲街弑〆低调 提交于 2020-01-06 09:54:34
问题 So, so far I have this: static SimpleDateFormat df = new SimpleDateFormat("dd MM yyyy"); jDateChooser8 = new com.toedter.calendar.JDateChooser(); when I parse the right date let's say this one: jDateChooser8.setDate(df.parse("24 07 1987")); it's ok, but when I try to parse "" (empty string) jDateChooser8.setDate(df.parse("")); I get an exeption: first line of error is: java.text.ParseException: Unparseable date: "" all I want to do is set date to "" , how to do it? 回答1: The javadoc for parse

Gson: java.text.ParseException: Unparseable date: “2018-04-09T09:00:00+02:00”

China☆狼群 提交于 2019-12-31 05:22:07
问题 How can I parse a string date in the format: "2018-04-09T09:00:00+02:00" Gson uses: new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US) But it gives the following exception: com.google.gson.JsonSyntaxException: 2018-04-09T09:00:00+02:00 at com.google.gson.DefaultDateTypeAdapter.deserializeToDate(DefaultDateTypeAdapter.java:107) at com.google.gson.DefaultDateTypeAdapter.deserialize(DefaultDateTypeAdapter.java:82) at com.google.gson.DefaultDateTypeAdapter.deserialize

Time parsing issue on Android

别等时光非礼了梦想. 提交于 2019-12-30 10:26:05
问题 I am getting a parse exception when trying to parse the time string 02:22 p.m. . I have the following conversion function: public static long convertdatetotimestamp(String datestring, String newdateformat, String olddateformat){ SimpleDateFormat originalFormat = new SimpleDateFormat(olddateformat,Locale.ROOT); SimpleDateFormat targetFormat = new SimpleDateFormat(newdateformat,Locale.ROOT); Date date = null; try { date = originalFormat.parse(datestring); String formattedDate = targetFormat

Proguard ParseException unknown option dump.txt

天涯浪子 提交于 2019-12-25 03:16:17
问题 I read alot of posts similar to this topic, but cant solve it anyway. Everytime I try to export my signed application with the obfuscator enabled, I get the following: [2011-12-23 13:26:35 - AppName] Proguard returned with error code 1. See console [2011-12-23 13:26:35 - AppName] proguard.ParseException: Unknown option 'android\AppName\proguard\dump.txt' in argument number 9 [2011-12-23 13:26:35 - AppName] at proguard.ConfigurationParser.parse(ConfigurationParser.java:170) [2011-12-23 13:26

Unexpected top-level exception after changing package name

一世执手 提交于 2019-12-24 13:58:02
问题 I am working on an Android Studio project and ran into a problem when I tried to create a package that started with a capital letter (I forgot what it was at this point, but that's not the issue at hand). So I changed the package name from Adapters to adapters and now I can no longer compile. I receive the following error message: com.android.dx.cf.iface.ParseException: class name (com/example/android/myAppName/adapters/AccountAdapter$ViewHolder) does not match path (com/example/android

Getting ParseException on Transport.send(message)

时光毁灭记忆、已成空白 提交于 2019-12-24 00:39:41
问题 For some reason I'm getting a javax.mail.internet.ParseException when I call Transport.send() on a MimeMessage. This worked before when it was only a plain text email, but when I changed it to have both text and html it started blowing up. Any ideas what I'm doing wrong? @Resource(mappedName = "java:/Mail") private Session mailer; public void sendMessage(String toEmailAddress, String subject, String content, String text) throws Exception { try { Message message = new MimeMessage(mailer);