See the reference documentation for the String class: String s = String.valueOf(date);

If your Long might be null and you don't want to get a 4-letter "null" string, you might use Objects.toString, like: String s = Objects.toString(date, null);


EDIT:

You reverse it using Long l = Long.valueOf(s); but in this direction you need to catch NumberFormatException

Answer from Gregory Pakosz on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › convert-a-string-to-an-long-in-java
How to Convert a String to an Long in Java ? - GeeksforGeeks
July 23, 2025 - ... // Java Program to Convert ...println("String : " + str); // Converting above string to long // using Long(String s) constructor Long num = new Long(str); // Printing the above long value System.out.println("Long : " + num); ...
🌐
Baeldung
baeldung.com › home › java › java string › convert string to long or long in java
Convert String to long or Long in Java | Baeldung
January 10, 2024 - Given our String, we can use the overloaded Long constructor that takes a String as an argument: ... This creates a new Long instance which can be converted to a primitive long by invoking the longValue() method.
Discussions

java - How to convert / cast long to String? - Stack Overflow
After choosing the date, I need to convert that long value to String, so that I can easily store the date value somewhere in database. I am new to Java and Blackberry development. More on stackoverflow.com
🌐 stackoverflow.com
How to converte String to Long? - Products - Jaspersoft Community
I have a String parameter "2012231211" and want to convert as Long data type for the SQL statement.I had tried add a new parameter and set the default value expression as ($P{field}.matches("[0-9]+") ? new java.lang.Long($P{field}) : new java.lang.Long(0))However, I got the following errors. "Err... More on community.jaspersoft.com
🌐 community.jaspersoft.com
January 27, 2015
How to convert String to long in Java? - Stack Overflow
Please note that the previous code ... provided String doesn't match with a signed long. Generally speaking, it is a good practice to use the static factory method valueOf(str) of a wrapper class like Integer, Boolean, Long, ... since most of them reuse instances whenever it is possible making them potentially more efficient in term of memory footprint than the corresponding parse methods or constructors. Excerpt from Effective Java Item 1 written ... More on stackoverflow.com
🌐 stackoverflow.com
[Java] How can I convert a string of long text into IPA?
Transcribing into IPA is difficult for a number of reasons. For example, which level of transcription are you after? Are you looking for the realized sounds or are you looking for the phonemes of the language? How are you planning on using this? How would you like to handle simple variations (such as the two possible vowel qualities in “the”)? How would you like to handle speaker errors? Etc. More on reddit.com
🌐 r/LanguageTechnology
6
1
July 27, 2018
People also ask

Is there any difference between converting string to long and int in Java?
The method is similar; use Long.parseLong() for long and Integer.parseInt() for int. Just ensure your input string fits within the range of the type you’re converting to.
🌐
wscubetech.com
wscubetech.com › resources › java › programs › string-to-long
Convert String to Long in Java (9 Programs)
Can I convert strings with commas like "1,000" to long in Java?
No, Long.parseLong() doesn't accept formatted numbers with commas. You need to remove commas first using replace(",", ""), then parse it. For example: Long.parseLong(str.replace(",", "")).
🌐
wscubetech.com
wscubetech.com › resources › java › programs › string-to-long
Convert String to Long in Java (9 Programs)
What’s the safest way to convert string to long in Java when the value might be wrong?
Wrap the parsing in a try-catch block. That way, if the string is invalid, your program won’t crash. You can also return a default value if parsing fails. This is the safest and cleanest approach.
🌐
wscubetech.com
wscubetech.com › resources › java › programs › string-to-long
Convert String to Long in Java (9 Programs)
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › String-to-long-in-Java
String to long in Java
The correct way to convert a String to long in Java is with the parseLong method of the wrapper class. The constructor conversion approach is deprecated! Use parseLong instead.
🌐
Jaspersoft Community
community.jaspersoft.com › forum
How to converte String to Long? - Products - Jaspersoft Community
January 27, 2015 - I have a String parameter "2012231211" and want to convert as Long data type for the SQL statement.I had tried add a new parameter and set the default value expression as ($P{field}.matches("[0-9]+") ? new java.lang.Long($P{field}) : new java.lang.Long(0))However, I got the following errors. "Err...
Find elsewhere
🌐
Medium
medium.com › @KavishaMathur › how-to-convert-long-to-string-in-java-15b02cf2538a
How to convert long to string in java? | by Kavisha Mathur | Medium
April 21, 2024 - There are several ways to do this depending on the user’s familiarity with the Java syntax and how concise they want their code to be. ... An amateur coder would know that expressions long to string will have an inbuilt command whose syntax is very much like the English expression. It takes a long value as the argument and gives out the converted string expression.
🌐
WsCube Tech
wscubetech.com › resources › java › programs › string-to-long
Convert String to Long in Java (9 Programs)
October 18, 2025 - Learn 9 easy ways to convert a String to Long in Java with examples. Explore methods like Long.parseLong(), Long.valueOf(), Long(String), and more.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-convert-string-to-long
Java Program to Convert String to Long - GeeksforGeeks
July 23, 2025 - To convert a String to Long in Java, we can use built-in methods provided by the Long class.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-long-to-string
Java long to String | DigitalOcean
August 3, 2022 - We can use Long class toString method to get the string representation of long in decimal points. Below code snippet shows you how to use it to convert long to string in java.
🌐
BeginnersBook
beginnersbook.com › 2015 › 05 › java-long-to-string
Java long to String Conversion
November 20, 2022 - public class JavaExample{ public static void main(String args[]){ //long values are suffixed with 'L' long l = 123456789L; //passing the long value to the toString() method String str = Long.toString(l); //Print the string value returned by Long.toString() method System.out.println("String ...
🌐
Udemy
blog.udemy.com › home › how to convert a long primitive data type to a string type in java?
How to Convert a Long Primitive Data Type to a String Type in Java? - Udemy Blog
December 4, 2019 - Wrapper classes have several static methods that will allow you to change a primitive variable to a String. A Java long type can be converted to String using the toString(long x).
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › Long.html
Long (Java SE 17 & JDK 17)
January 20, 2026 - ... Deprecated, for removal: This API element is subject to removal in a future version. It is rarely appropriate to use this constructor. Use parseLong(String) to convert a string to a long primitive, or use valueOf(String) to convert a string to a Long object.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › long-to-String-in-Java
long to String in Java
The conversion of a long to a String with the plus operator works with any of the eight Java primitive types. By the way, you can also go the other way. Here are several ways to convert a String to a long in Java.
🌐
Makeinjava
makeinjava.com › home › convert string variable to long in java (example)
Convert String variable to Long in java (example)
January 4, 2024 - Java provides multiple methods for string-to-long conversion, each with distinct functionalities. The primary method, Long.parseLong(), is a straightforward and widely used approach to convert a string containing numeric characters into a long primitive data type.
🌐
Coderanch
coderanch.com › t › 376931 › java › Converting-String-long
Converting String to long (Java in General forum at Coderanch)
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums · this forum made possible by our volunteer staff, including ... ... Hello, I am attempting to convert a string read from a database into a long, I figured out most of it: String amt = "3454"; long Amount = Long.parseLong(amt); But the problem is that the String actually being read is not "3454" but of the form "0000003454".
🌐
Codekru
codekru.com › home › how to convert string to long in java
How to convert String to long in Java - Codekru
July 9, 2021 - Deprecated. It is rarely appropriate to use this constructor. Use parseLong(String) to convert a string to a long primitive, or use valueOf(String) to convert a string to a Long object.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-long-to-string-conversion
Java Program to Convert Long to String - GeeksforGeeks
July 23, 2025 - For converting any data type to string type, we can simply add/+ empty string indicated by double quotes("). ... // Java program to convert Long to String // using + operator public class GFG { // main method public static void main(String args[]) ...