Here you can find the source of parseToUTCDate(String timestamp, String pattern)
Parameter | Description |
---|---|
timestamp | the timestamp |
pattern | the pattern |
public static Date parseToUTCDate(String timestamp, String pattern)
//package com.java2s; /*//from w w w . j a v a2 s . com * DateUtil.java * Copyright (c) 2014, EcoFactor, All Rights Reserved. * * This software is the confidential and proprietary information of EcoFactor * ("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 * EcoFactor. */ import java.text.ParseException; import java.util.Calendar; import java.util.Date; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; public class Main { /** * Format. * @param timestamp the timestamp * @param pattern the pattern * @return the string */ public static Date parseToUTCDate(String timestamp, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); Date date = fmt.parseDateTime(timestamp).toDate(); return date; } /** * To date. * @param calendar the calendar * @return the date * @throws ParseException the parse exception */ public static Date toDate(final Calendar calendar) throws ParseException { Date date = new Date(); date = calendar.getTime(); return date; } }