Here you can find the source of parseIcalDateToString(Date date, TimeZone tz)
Parameter | Description |
---|---|
date | the date |
tz | timezone |
private static String parseIcalDateToString(Date date, TimeZone tz)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { /**//from ww w . java 2 s.c o m * Pase the Ical Date to a String * * @param date * the date * @param tz * timezone * @return the parsed Date as a String */ private static String parseIcalDateToString(Date date, TimeZone tz) { StringBuilder sb = new StringBuilder(); SimpleDateFormat timeFormat = new SimpleDateFormat("HHmm", Locale.getDefault()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); if (tz != null) { timeFormat.setTimeZone(tz); dateFormat.setTimeZone(tz); } else { timeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } sb.append(dateFormat.format(date)); sb.append("T"); sb.append(timeFormat.format(date)); sb.append("00"); if (tz == null) sb.append('Z'); return sb.toString(); } }