Java SimpleDateFormat parse String to date with offset
import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String[] args) { String text = "asdf 09/19/2028"; // Create a pattern for the date text "09/19/2028" String pattern = "MM/dd/yyyy"; // Create a simple date format object to represent this pattern SimpleDateFormat simpleFormatter = new SimpleDateFormat(pattern); ParsePosition startPos = new ParsePosition(5); // Parse the text Date parsedDate = simpleFormatter.parse(text, startPos); System.out.println(parsedDate); }/*w ww. j av a2 s .c o m*/ }