How to compare the size of two String type timestamps in JAVA?
为情所困
为情所困 2017-06-12 09:27:09
0
4
1239

1. The timestamp obtained from the database is of type String. It needs to be compared with the current time to determine whether the login has expired.
Generate the current time of long type, force the String type to long type and report an error. The code is as follows :

   long currentTime = System.currentTimeMillis(); //当前时间
//        System.out.println("currentTime" + currentTime);
        long expireTime = Long.parseLong(token1.getExpireTime()); //过期时间
//        System.out.println("expireTime : " + expireTime);

The error message is as follows:

java.lang.NumberFormatException: For input string: "1496733869286 "
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:589)
    at java.lang.Long.parseLong(Long.java:631)
    at com.tustcs.matrix.util.Interceptor.preHandle(Interceptor.java:45)
    at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:954)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)

2. Found that the current time output by the console is wrong
3. The test is as follows:

4. The database information is as follows:

为情所困
为情所困

reply all(4)
洪涛

trim once and then long

给我你的怀抱

java.lang.NumberFormatException: For input string: "1496733869286 "You see there is a space behind you.

PS. You don’t call this “String typeforced conversionan error to long type”, the concept is wrong

伊谢尔伦

For input string: "1496733869286 " Why is there a space after the number?

代言

long i = 1234893584;String s = String.valueOf(i);turn like this

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!