List of usage examples for java.util TimeZone getTimeZone
public static TimeZone getTimeZone(ZoneId zoneId)
From source file:ru.retbansk.utils.scheduled.impl.ReadEmailAndConvertToXmlSpringImplTest.java
@BeforeClass public static void beforeClass() { reader = new ReadEmailAndConvertToXmlSpringImpl(); try {/* w ww . ja v a 2 s . com*/ UsefulMethods.populate(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } DayReport dayReport = new DayReport(); dayReport.setPersonId(USER2); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+3")); calendar.set(2012, Calendar.OCTOBER, 18); dayReport.setCalendar(calendar); List<TaskReport> taskList = new ArrayList<TaskReport>(); TaskReport taskReport = new TaskReport(); taskReport.setDate(calendar.getTime()); taskReport.setElapsedTime(1); taskReport.setStatus(TEST_STRING); taskReport.setWorkDescription(TEST_STRING2); taskList.add(taskReport); dayReport.setReportList(taskList); dayReportSet = new HashSet<DayReport>(); dayReportSet.add(dayReport); }
From source file:io.github.sparta.helpers.date.DateUtil.java
/** * convert server date to new date with user Locale. * /*from ww w . j a v a2s.com*/ * @param userTimeZone * user TimeZone id * @param serverDate * date in server's Local * @return serverDate data in user's Local */ public static Date convertToUserDate(String userTimeZone, Date serverDate) { TimeZone userLocal = TimeZone.getTimeZone(userTimeZone); int rawOffset = userLocal.getRawOffset() - TimeZone.getDefault().getRawOffset(); return new Date(serverDate.getTime() + rawOffset); }
From source file:name.yumao.douyu.http.PlaylistDownloader.java
private static String getPath() { Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00")); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd^HH-mm-ss"); String path = "record" + File.separator + roomnum + File.separator + simpleDateFormat.format(calendar.getTime()); String pathfile = path + File.separator + simpleDateFormat2.format(calendar.getTime()); return pathfile + ".mp5"; }
From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.SetDateBoltTest.java
@Test public void testEnrichDataswift(@Mocked final LogRecord record) throws Exception { final Calendar calendar = Calendar.getInstance(); calendar.clear();//from w w w. j a v a 2 s . c o m calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.set(2014, Calendar.JUNE, 10, 20, 22, 4); bolt.dateFields = Arrays.asList("interaction.created_at"); bolt.dateFormat = "EEE, dd MMM yyyy HH:mm:ss Z"; new Expectations() { { record.getValue(bolt.dateFields.get(0)); result = "Tue, 10 Jun 2014 20:22:04 +0000"; record.setDate(calendar.getTime()); } }; bolt.process(record); }
From source file:org.ambraproject.action.HomepageActionTest.java
public HomepageActionTest() { dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); }
From source file:org.lieuofs.util.dao.FichierOFSTxtDao.java
/**************************************************/ public FichierOFSTxtDao() { super();//from w ww . j a v a 2 s . co m dateFmt = new SimpleDateFormat("dd.MM.yyyy"); dateFmt.setTimeZone(TimeZone.getTimeZone("Europe/Zurich")); }
From source file:Main.java
private static int getDiffTimeZoneRawOffset(String timeZoneId) { return TimeZone.getDefault().getRawOffset() - TimeZone.getTimeZone(timeZoneId).getRawOffset(); }
From source file:com.adobe.acs.commons.version.impl.EvolutionConfig.java
public static String printObject(Object obj) { if (obj == null) { return ""; }// w w w . j a v a 2 s . co m if (obj instanceof String) { return (String) obj; } else if (obj instanceof String[]) { String[] values = (String[]) obj; StringBuilder result = new StringBuilder(); result.append("["); for (int i = 0; i < values.length; i++) { result.append(values[i]); if (i != (values.length - 1)) { result.append(", "); } } result.append("]"); return result.toString(); } else if (obj instanceof Calendar) { Calendar value = (Calendar) obj; DateFormat dateFormat = DateFormat.getDateTimeInstance(); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(value.getTime()); } else { return obj.toString(); } }
From source file:eu.annocultor.converters.solr.SolrPeriodsTagger.java
static Date parseDate(String dateString, String affixToTryOnYearOnly) { try {/* w w w .j a v a 2s . co m*/ if (dateString.length() == 4 && dateString.matches("\\d\\d\\d\\d")) { dateString += affixToTryOnYearOnly; } DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); if (StringUtils.isEmpty(dateString)) { return null; } return dateFormat.parse(dateString); } catch (Exception e) { System.out.println(e.getMessage()); return null; } }
From source file:DateUtility.java
public static Date parseW3CDTFDate(String dateString) { Matcher m = null;/*from w w w.java 2 s . c om*/ if ((m = W3CDTF_FORMAT1.matcher(dateString)).matches()) { TimeZone tz; if ("Z".equals(m.group(7))) { tz = TimeZone.getTimeZone("GMT+00:00"); } else { tz = TimeZone.getTimeZone("GMT" + m.group(7)); } Calendar c = Calendar.getInstance(tz); int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)) - 1; int date = Integer.parseInt(m.group(3)); int hour = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); int second = Integer.parseInt(m.group(6)); c.set(year, month, date, hour, minute, second); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } if ((m = W3CDTF_FORMAT2.matcher(dateString)).matches()) { TimeZone tz; if ("Z".equals(m.group(6))) { tz = TimeZone.getTimeZone("GMT+00:00"); } else { tz = TimeZone.getTimeZone("GMT" + m.group(6)); } Calendar c = Calendar.getInstance(tz); int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)) - 1; int date = Integer.parseInt(m.group(3)); int hour = Integer.parseInt(m.group(4)); int minute = Integer.parseInt(m.group(5)); c.set(year, month, date, hour, minute, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } if ((m = W3CDTF_FORMAT3.matcher(dateString)).matches()) { Calendar c = Calendar.getInstance(); int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)) - 1; int date = Integer.parseInt(m.group(3)); c.set(year, month, date, 0, 0, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } if ((m = W3CDTF_FORMAT4.matcher(dateString)).matches()) { Calendar c = Calendar.getInstance(); int year = Integer.parseInt(m.group(1)); int month = Integer.parseInt(m.group(2)) - 1; c.set(year, month, 1, 0, 0, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } if ((m = W3CDTF_FORMAT5.matcher(dateString)).matches()) { Calendar c = Calendar.getInstance(); int year = Integer.parseInt(m.group(1)); c.set(year, 0, 1, 0, 0, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } return null; }