Here you can find the source of toDateWithTimezone(String dateTime, String pattern)
Parameter | Description |
---|---|
dateTime | the date time |
pattern | the pattern |
Parameter | Description |
---|---|
ParseException | the parse exception |
public static Date toDateWithTimezone(String dateTime, String pattern) throws ParseException
//package com.java2s; /*//from ww w . j a va 2 s .c o m * DateUtil.java * Copyright (c) 2014, CODEROAD, All Rights Reserved. * * This software is the confidential and proprietary information of CODEROAD * ("Confidential Information"). You shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement you entered into with * CODEROAD. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** * To date with timezone. * * @param dateTime the date time * @param pattern the pattern * @return the date * @throws ParseException the parse exception */ public static Date toDateWithTimezone(String dateTime, String pattern) throws ParseException { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.ENGLISH); date = sdf.parse(dateTime); return date; } }